Part Number Hot Search : 
SMF6533 A1A22 CS5371 SA555P DPD24L15 330M2 JANS4N47 BC859
Product Description
Full Text Search
 

To Download HT46R0664 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  enhanced a/d+lcd type 8-bit otp mcu HT46R0664 revision: v.1.00 date: ???? st 1?? ? 011 ????st 1?? ? 011
rev. 1.00 ? ????st 1?? ? 011 rev. 1.00 3 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu table of contents eates cpu feat?res ......................................................................................................................... 5 peripheral feat?res ................................................................................................................. 5 general description ........................................................................................ 6 block dia?ram .................................................................................................. 6 pin ?ssi?nment ................................................................................................ 6 pin description ................................................................................................ 7 ?bsol?te maxim?m ratin?s ............................................................................ 9 d.c.characteristics ........................................................................................ 10 ?.c. characteristics ........................................................................................ 11 lvd&lvr electrical characteristics ............................................................ 1? ?dc electrical characteristics ..................................................................... 1? power-on reset characteristics ................................................................... 13 system ?rchitect?re ...................................................................................... 13 clockin? and pipelinin? ......................................................................................................... 13 pro?ram co?nter C pc .......................................................................................................... 14 stack ..................................................................................................................................... 15 ?rithmetic and lo?ic unit C ?lu ........................................................................................... 15 pro?am memory ............................................................................................. 16 str?ct?re ................................................................................................................................ 16 special vectors ..................................................................................................................... 16 look-? p table ........................................................................................................................ 17 table pro ?ram example ........................................................................................................ 17 data memory .................................................................................................. 19 str?ct?re ................................................................................................................................ 19 general p?rpose data memory ............................................................................................ 19 display memory .................................................................................................................... ?0 special p?rpose data memory ............................................................................................. ?0 special f?nction re?ister ............................................................................. ?1 indirect ?ddressin? re?isters C i?r0? i?r1 ......................................................................... ?1 memory pointers C mp0? mp1 .............................................................................................. ?1 ?cc?m? lator C ?cc ............................................................................................................... ?? bank pointer C bp ................................................................................................................. ?? pro?ram co?nter low re?ister C pcl .................................................................................. ?? look-? p table re? isters C tblp ? tblh ................................................................................ ?3 stat?s re?ister C st ? tus .................................................................................................... ?3 system control re?isters C ctrl0? ctrl1? ctrl?? ctrl3? ctrl4 ................................ ?4 oscillator ....................................................................................................... ?7 oscillator overview ............................................................................................................... ?7
rev. 1.00 ? ????st 1?? ? 011 rev. 1.00 3 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu system clock confgurations ................................................................................................ ?7 external crystal/resonator oscillator C hxt ........................................................................ ?7 external rc oscillator C erc ............................................................................................... ?8 internal rc oscillator C hirc ............................................................................................... ?8 external 3?768hz crystal oscillator C lxt ........................................................................... ?8 lxt oscillator low power f ?nction ...................................................................................... ?9 internal low speed oscillator C lirc ................................................................................... ?9 operating modes .......................................................................................... 30 mode types and selection .................................................................................................... 30 operatin? mode control ........................................................................................................ 30 mode switchin? ..................................................................................................................... 31 standby c?rrent considerations ........................................................................................... 31 wake- ?p ................................................................................................................................ 31 watchdog timer ............................................................................................. 33 watchdo ? timer clock so?rce .............................................................................................. 33 watchdo ? timer control re?ister ......................................................................................... 33 watchdo ? timer operation ................................................................................................... 34 reset and initialisation .................................................................................. 36 reset f?nctions .................................................................................................................... 36 reset initial conditions ......................................................................................................... 39 input/output ports ......................................................................................... 41 p?ll-hi?h resistors ................................................................................................................ 41 port ? wake- ?p ..................................................................................................................... 41 i/o port control re?isters ..................................................................................................... 4? pin-shared f?nctions ............................................................................................................ 4? pin remapping confguration ............................................................................................... 43 i/o pin str?ct?res .................................................................................................................. 43 pro?rammin? considerations ................................................................................................ 44 timer/event counter ..................................................................................... 45 confguring the timer/event counter input clock source .................................................... 45 timer re ? isters C tmr0? tmr1 ........................................................................................... 46 timer control re ? isters C tmr0c? tmr1c .......................................................................... 46 timer mode ........................................................................................................................... 48 event co?nter mode ............................................................................................................. 49 p?lse width capt?re mode ................................................................................................... 49 prescaler ............................................................................................................................... 50 pfd f?nction ........................................................................................................................ 51 i/o interfacin? ........................................................................................................................ 51 pro?rammin? considerations ................................................................................................ 51 timer pro ?ram example ....................................................................................................... 5? pulse width modulator .................................................................................. 53 pwm operation ..................................................................................................................... 53 6+? pwm mode .................................................................................................................... 54
rev. 1.00 4 ????st 1?? ? 011 rev. 1.00 5 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu 7+1 pwm mode .................................................................................................................... 54 pwm o?tp?t control ............................................................................................................. 55 pwm pro?rammin? example ................................................................................................ 55 analog to digital converter ......................................................................... 56 ?/d overview ........................................................................................................................ 56 ?/d converter data re?isters C ?drl? ?drh ..................................................................... 56 ? /d converter control re? isters C ?dcr? ?csr? ?ncsr0? ?ncsr1 ................................ 57 ?/d operation ....................................................................................................................... 59 ?/d inp?t pins ....................................................................................................................... 60 s?mmary of ?/d conversion steps ....................................................................................... 60 ? /d conversion timin? ......................................................................................................... 61 pro?rammin? considerations ................................................................................................ 61 ? /d transfer f?nction ........................................................................................................... 61 ?/d pro?rammin? example ................................................................................................... 6? buzzer ............................................................................................................ 64 interrupts ........................................................................................................ 65 interr?pt re?isters ................................................................................................................. 65 interr?pt operation ................................................................................................................ 67 interr?pt priority ..................................................................................................................... 69 m?lti-f?nction interr?pt .......................................................................................................... 69 ?/d converter interr?pt ......................................................................................................... 70 timer/event co ?nter interr?pt ............................................................................................... 70 time base interr ?pts ............................................................................................................. 70 interr? pt wake-?p f?nction ................................................................................................... 71 pro?rammin? considerations ................................................................................................ 71 lcd function ................................................................................................. 72 display memory .................................................................................................................... 73 lcd re?isters ....................................................................................................................... 73 lcd clock so?rce ................................................................................................................. 75 lcd driver o?tp?t ................................................................................................................. 75 lcd volta ?e so?rce and biasin? .......................................................................................... 75 low voltage detector C lvd ......................................................................... 76 lvd re ?ister ......................................................................................................................... 76 lvd operation ....................................................................................................................... 77 confguration options ................................................................................... 77 application circuits ....................................................................................... 78 instruction set summary .............................................................................. 79 table conventions ................................................................................................................. 79 instruction defnition ..................................................................................... 81 package information ..................................................................................... 91 44-pin qfp (10mm10mm) o ?tline dimensions .................................................................. 91
rev. 1.00 4 ????st 1?? ? 011 rev. 1.00 5 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu features cpu features operating voltage: f sys = 4mhz: 2.2v ? 5.5v f sys =8mhz: 3.0v ? 5.5v f sys =12mhz: 4.5v ? 5.5v up to 0.5s instruction cycle with 8mhz system clock at v dd =5v power down and wake-up functions to reduce power consumption oscillator types: external crystal -- hxt external rc -- erc external 32768hz crystal -- lxt internal rc -- hirc internal 32khz rc -- lirc multi-mode operation: normal, slow, idle and sleep fully integrated internal 4mhz, 8mhz and 12mhz oscillator requires no external components all instructions executed in one or two instruction cycles table read instructions 63 powerful instructions up to 6-level stack bit manipulation instruction peripheral features up to 42 bidirectional i/o lines up to 12 channel 12-bit adc up to 2 channel 8-bit pwm data memory: 2248 program memory: 4k16 watchdog timer function 4 pin-shared external interrupts up to two 8-bit programmable timer/event counter with overfow interrupt and prescaler low voltage reset function low voltage detect function time base functions buzzer function package: 44qfp
rev. 1.00 6 ????st 1?? ? 011 rev. 1.00 7 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu general description the enhanced a/d type with lcd is a 8-bit high performance, risc architecture microcontroller specifcally designed for applications that interface directly to analog signals and which require an lcd interface. the device includes an integrated multi-channel analog to digital converter, pulse width modulation outputs and an lcd driver. the benefits of integrated a/d, lcd, and pwm functions, in addition to low power consumption, high performance, i/o fexibility, timer functions, oscillator options, power down and wake-up functions, watchdog timer and low voltage reset, combine to provide device with a huge range of functional options while still main taining a high level of cost effectiveness. the fully integrated system oscillator hirc, which requires no external components and which has three frequency selections, opens up a huge range of new application possibilities for the device, some of which may include industrial control, consumer products, household appliances subsystem controllers, etc. block diagram                 
   
             
?    ?     ??    
?   ??     pin assignment (4 4 - q f p ) 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 4 4 4 3 4 2 4 1 4 0 3 9 3 8 3 7 3 6 3 5 3 4 1 2 3 4 5 6 7 8 9 1 0 1 1 3 3 3 2 3 1 3 0 2 9 2 8 2 7 2 6 2 5 2 4 2 3 pe2/seg18/int0 pa0/int1/pwm0 pa1/[tc0]/tc1/int2 pa2/[tc1]/tc0/int3 v d d v ss pa5/osc2/an11 pa6/osc1/an10 pf0/an9 pa4/xt1 pa3/xt2 pb3/an0 pb2/pfd/an1 pb1/buz/an2 pb0/pwm1/an3 pe6/an4/seg22/com4 pe5/an5/seg21/com5 pe4/an6/seg20/com6 pf2/avref pe3/an7/seg19/com7 pf1/an8 pa7 pc6/seg6 pc5/seg5 pc4/seg4 pc3/seg3 pc2/seg2 pc1/seg1 pc0/seg0 pb7/com0 pb6/com1 pb5/com2 pb4/com3 pc7/seg7 pd0/seg8 pd1/seg9 pd2/seg10 pd3/seg11 pd4/seg12 pd5/seg13 pd6/seg14 pd7/seg15 pe0/seg16 pe1/seg17 note: 1. bracketed pin names indicate non-default pinout remapping locations. 2. if the pin-shared pin functions have multiple outputs simultaneously, its pin names at the right side of the / sign can be used for higher priority.
rev. 1.00 6 ????st 1?? ? 011 rev. 1.00 7 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu pin description pin name function opt i/t o/t description p ?0/int1/pwm 0 p? 0 p ?pu p? wk st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p. int1 st external interr?pt inp?t pwm0 ctrl0 cmos pwm o?tp?t p ?1/int?/tc1 / [ tc0 ] p? 1 p ?pu p? wk st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p. int? st external interr?pt inp?t tc1 st external timer 1 clock inp ?t tc0 st external timer 0 clock inp ?t p ??/int3/tc0 / [ tc1 ] p ?? p ?pu p? wk st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p. int3 st external interr?pt inp?t tc0 st external timer 0 clock inp ?t tc1 st external timer 1 clock inp ?t p ?3/xt? p? 3 p ?pu p? wk st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p. xt? co lxt low freq?ency crystal pin p ?4/xt1 p? 4 p ?pu p? wk st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p. xt1 co lxt low freq?ency crystal pin p ?5/osc?/? n11 p? 5 p ?pu p? wk st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p. osc? co osc oscillator pin ? n11 ?ncsr1 ?n ? /d channel 11 p ?6/osc1/?n10 p? 6 p ?pu p? wk st cmos general p?rpose i/o. re?ister enabled p?ll-?p and wake-?p. osc1 co osc oscillator pin ?n10 ?ncsr1 ?n ?/d channel 10 p? 7 p? 7 p? wk st nmos general p?rpose i/o. re?ister enabled wake-?p. pb0/pwm1/?n3 pb0 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. pwm1 ctrl0 cmos pwm1 o?tp?t ?n3 ?ncsr0 ?n ?/d channel 3 pb1/buz/?n? pb1 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. buz ctrl? cmos b?zzer o?tp?t ?n? ?ncsr0 ?n ?/d channel ? pb?/pfd/?n1 pb? pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. pfd ctrl0 cmos pfd o?tp?t ?n1 ?ncsr0 ?n ?/d channel 1 pb3/?n0 pb3 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. ?n0 ?ncsr0 ?n ?/d channel 0 pb4/com3 pb4 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. com3 lcdo com lcd com port pb5/com? pb5 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. com? lcdo com lcd com port pb6/com1 pb6 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. com1 lcdo com lcd com port pb7/com0 pb7 pbpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. com0 lcdo com lcd com port
rev. 1.00 8 ????st 1?? ? 011 rev. 1.00 9 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu pin name function opt i/t o/t description pc0/seg0 pc0 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg0 lcdo cmos lcd se?ment port pc1/seg1 pc1 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg1 lcdo cmos lcd se?ment port pc?/seg? pc? pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg? lcdo cmos lcd se?ment port pc3/seg3 pc3 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg3 lcdo cmos lcd se?ment port pc4/seg4 pc4 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg4 lcdo cmos lcd se?ment port pc5/seg5 pc5 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg5 lcdo cmos lcd se?ment port pc6/seg6 pc6 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg6 lcdo cmos lcd se?ment port pc7/seg7 pc7 pcpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg7 lcdo cmos lcd se?ment port pd0/seg8 pd0 pdpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg8 lcdo cmos lcd se?ment port pd1/seg9 pd1 pdpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg9 lcdo cmos lcd se?ment port pd?/seg10 pd? pdpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg10 lcdo cmos lcd se?ment port pd3/seg11 pd3 pdpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg11 lcdo cmos lcd se?ment port pd4/seg1? pd4 pdpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg1? lcdo cmos lcd se?ment port pd5/seg13 pd5 pdpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg13 lcdo cmos lcd se?ment port pd6/seg14 pd6 pdpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg14 lcdo cmos lcd se?ment port pd7/seg15 pd7 pdpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg15 lcdo cmos lcd se?ment port pe0/seg16 pe0 pepu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg16 lcdo cmos lcd se?ment port pe1/seg17 pe1 pepu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. seg17 lcdo cmos lcd se?ment port pe?/int0/ seg18 pe? pepu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. int0 st external interr?pt inp?t seg18 lcdo cmos lcd se?ment port pe3/?n7/ seg19/com7 pe3 pepu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. ?n7 ?ncsr0 ?n ?/d channel 7 seg19 lcdo cmos lcd se?ment port com7 lcdo com lcd com port pe4/?n6/ seg?0/com6 pe4 pepu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. ?n6 ?ncsr0 ?n ?/d channel 6 seg?0 lcdo cmos lcd se?ment port com6 lcdo com lcd com port
rev. 1.00 8 ????st 1?? ? 011 rev. 1.00 9 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu pin name function opt i/t o/t description pe5/?n5/ seg?1/com5 pe5 pepu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. ?n5 ?ncsr0 ?n ?/d channel 5 seg?1 lcdo cmos lcd se?ment port com5 lcdo com lcd com port pe6/?n4/ seg??/com4 pe6 pepu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. ?n4 ?ncsr0 ?n ?/d channel 4 seg?? lcdo cmos lcd se?ment port com4 lcdo com lcd com p ort pf0/?n9 pf0 pfpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. ?n9 ?ncsr1 ?n ?/d channel 9 pf1/?n8 pf1 pfpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. ?n8 ?ncsr1 ?n ?/d channel 8 pf?/? vref pf? pfpu st cmos general p?rpose i/o. re?ister enabled p?ll-?p. ? vref ?csr ?n ?dc reference inp?t vdd vdd pwr power s?pply vss vss pwr gro?nd legend: i/t: input type; o/t: output type opt: optional by confguration option (co) or register option pwr: power; co: confguration option st: schmitt trigger input; cmos: cmos output; an: analog input com: lcd com nmos: nmos output osc: high frequency crystal oscillator lxt: low frequency crystal oscillator absolute maximum ratings supply voltage ................................................................................................ v ss ?0.3v to v ss +6.0v input voltage .................................................................................................. v ss ? 0.3v to v dd +0.3v storage temperature ................................................................................................... -50 c to 125c operating temperature ................................................................................................. -40 c to 85 c i oh total .................................................................................................................................. -100ma i ol total ................................................................................................................................... 100ma total power dissipation ........................................................................................................ 500mw note: these are stress ratings only. stresses exceeding the range specified under "absolute maximum ratings" may cause substantial damage to the device. functional operation of this device at other conditions beyond those listed in the specifcation is not implied and prolonged exposure to extreme conditions may affect device reliability.
rev. 1.00 10 ????st 1?? ? 011 rev. 1.00 11 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu d.c.characteristics ta= ?5c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operatin? volta?e f sys =4mh z ?.? 5.5 v f sys =8mhz 3. 0 5.5 v f sys =1?mhz 4.5 5.5 v i dd1 operatin? c?rrent (hxt ? hirc? erc) 3v no load? f sys =4mhz? ? dc off 1 ? m? 5v ?.5 5 m? i dd? operatin? c?rrent (hxt ? hirc? erc) 5v ? dc off 4 8 m? i dd3 operatin? c?rrent (hxt ? hirc? erc) 5v no load? f sys =1?mhz? ? dc off 6 1? m? i dd4 operatin? c?rrent (hirc+lxt ? slow mode) 3v no load? f sys =3?768hz? ? dc off ?0 30 a 5v 40 60 i stb1 standby c?rrent (lirc on? lxt off) 3v no load? system h? lt 5 a 5v 10 a i stb? standby c?rrent (lirc off ? lxt off) 3v no load? system h? lt 1 a 5v ? a i stb3 standby c?rrent (lirc off ? lxt on) 3v no load? system h? lt ? lxt slowly start- ?p 5 a 5v 10 a v il1 inp? t low volta?e for p ??pb?pc?pd?pe?pf ?tc0?tc1?int 5v 0 1.5 v 0 0.?v dd v v ih1 inp?t hi? h volta?e for p ??pb?pc?pd?pe?pf ?tc0?tc1?int 5v 3.5 5 v 0.8v dd v dd v i ol1 i/o port sink c?rrent (p ??pb?pc?pd?pe?pf) 3v v ol =0.1v dd 4 8 m? 5v 10 ?0 m? i oh1 i/o port? so?rce c?rrent (p ??pb?pc?pd?pe?pf) 3v v oh =0.9v dd -? -4 m? 5v -5 -10 m? i ol? p ?7 sink c?rrent 5v v ol =0.1v dd ? 3 m? i lcd_bi?s r-type lcd bias c ?rrent 5v lcdc.rsel[1:0]=00? 1/4 bias -?0% 8.33 ?0% a lcdc.rsel[1:0]=01? 1/4 bias -?0% 16.66 ?0% lcdc.rsel[1:0]=10? 1/4 bias -?0% 50 ?0% lcdc.rsel[1:0]=11 ? 1/4 bias -?0% 166.66 ?0% i lcd_ol lcd common and se?ment c?rrent 3v v ol =0.1v dd ?10 4?0 a 5v 350 700 i lcd_oh lcd common and se?ment c?rrent 3v v oh =0.9v dd -80 -160 a 5v -180 -360 r ph p?ll-hi?h resistance of i/o ports 3v ?0 60 100 k 5v 10 30 50 k
rev. 1.00 10 ????st 1?? ? 011 rev. 1.00 11 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu a.c. characteristics ta= ?5c symbol parameter test conditions min. typ. max. unit v dd condition f sys system clock (hxt ? hirc? erc) ?.?~5.5v 0.4 4 mhz 3. 0 ~5.5v 0.4 8 mhz 4.5~5.5v 0.4 1? mhz f hirc system clock (hirc) ?.?~5.5v -10% 4 +10% mhz ?.?~5.5v -10% 8 +10% mhz ?.?~5.5v -10% 1? +10% mhz 3/5v -?% 4 +?% mhz 3/5v -?% 8 +?% mhz 5v -?% 1? +?% mhz 3/5v -5% 4 +5% mhz 3/5v -5% 8 +5% mhz 5v ta=0~70c -5% 1? +5% mhz ?.?~3.6v ta=0~70c -8% 4 +8% mhz 3.0~5.5v ta=0~70c -8% 4 +8% mhz 3.0~5.5v ta=0~70c -8% 8 +8% mhz 4.5~5.5v ta=0~70c -8% 1? +8% mhz ?.?~3.6v ta=-40 c ~85c -1?% 4 +1?% mhz 3.0~5.5v ta=-40 c ~85c -1?% 4 +1?% mhz 3.0~5.5v ta=-40 c ~85c -1?% 8 +1?% mhz 4.5~5.5v ta=-40 c ~85c -1?% 1? +1?% mhz f erc system clock (erc) 3/5v r=1?0k ? ta = -40c~85c -10% 4 +10% mhz 5v r=120k -?% 4 +?% mhz 5v ta=0~70c, r=120k -5% 4 +5% mhz 5v ta=-40 c ~85c, r=120k -7% 4 +7% mhz ?.?~5.5v ta=-40 c ~85c, r=120k -11% 4 +11% mhz f lirc low speed internal rc oscillator clock (lirc) 5v -10% 3? +10% khz ?.?v~5.5v ta=-40c ~ 85c -50% 3? +60% khz t timer tcn inp?t pin minim?m p?lse width 0. 3 1 1.5 s t ss t system start-? p timer period (wake-?p from h? lt ? f sys off at h ? lt state) f sys =hxt or lxt osc 1?8 t sys f sys =erc or hirc osc ? system start- ? p timer period (wake- ?p from power down f sys on at power down state) ? t i nt interr?pt minim?m p?lse width 1 3.3 5 s t rstd system reset delay time (power on reset) ?5 50 100 ms system reset delay time (?ny reset except power on reset) 8.3 16.7 33.3 ms note: t sys =1/f sys
rev. 1.00 1? ????st 1?? ? 011 rev. 1.00 13 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu lvd&lvr electrical characteristics symbol parameter test conditions min. typ. max. unit v dd conditions v lvr1 low volta ? e reset volta?e lvr enable ? ?.1v option -5% ?.1 +5% v v lvr ? lvr enable ? ?.55v option ?.55 v v lvr3 lvr enable ? 3.15v option 3.15 v v lvr 4 lvr enable ? 3.8v optio n 3.8 v v lvd1 low volta ? e detector volta?e lvden=1 ? v lvd =?.0v -5% ?.0 +5% v v lvd ? lvden=1 ? v lvd =?.?v ?.? v v lvd3 lvden=1 ? v lvd =?.4v ?.4 v v lvd4 lvden=1 ? v lvd =?.7v ?.7 v v lvd5 lvden=1 ? v lvd =3.0v 3.0 v v lvd6 lvden=1 ? v lvd =3.3v 3.3 v v lvd7 lvden=1 ? v lvd =3.6v 3.6 v v lvd8 lvden=1 ? v lvd =4.0v 4.0 v i lvr ?dditional power cons?mption if lvr is ? sed 3v lvr enabled 30 45 a 5v 60 90 a i lvd ?dditional power cons?mption if lvd is ? sed 3v lvd disablelvd enable (lvr enable) 30 45 a 5v 60 90 a t lvr low volta ?e width to reset 1?0 ?40 480 s t lvd low volta ?e width to interr?pt ?0 45 90 s t lvds lvdo stable time for lvr enable, lvd offon 15 s t sreset software reset width to reset 45 90 1?0 s adc electrical characteristics ta= ?5c symbol parameter test conditions min. typ. max. unit v dd conditions dnl ? /d differential non-linearity 3v ?v ref =v dd ? t ?d =0.5s -? +? lsb 5v inl ?dc inte?ral non-linearity 3v ?v ref =v dd ? t ?d =0.5s -4 +4 lsb 5v 5v i ?dc ?dditional power cons?mption if ?/d converter is used 3v no load (t ?d =0.5s ) 0.5 m? 5v 0.6 m? t ?d ?/d converter clock period ?.7v~5.5v 0.5 10 s t ?dc ? /d conversion time (incl? de sample and hold time) ?.7v~5.5v 1? - bit ?dc 16 t ?dc t on?st ? /d converter on-to-start time ? s
rev. 1.00 1? ????st 1?? ? 011 rev. 1.00 13 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu power-on reset characteristics ta= ?5c symbol parameter test conditions min. typ. max. unit v dd conditions v por v dd start volta ?e to ens?re power-on reset 100 mv rr vdd v dd raisin? rate to ens?re power-on reset 0.035 v/ms t por minim? m time for v dd stays at v por to ens? re power-on reset 1 ms              system architecture a key factor in the high-performance features of the holtek range of microcontrollers is attributed to their internal system architecture. the range of device takes advantage of the usual features found within risc microcontrollers providing increased speed of operation and enhanced performance. the pipelining scheme is implemented in such a way that instruction fetching and instruction execution are overlapped, hence instructions are effectively executed in one cycle, with the exception of branch or call instructions. an 8-bit wide alu is used in practically all instruction set operations, which carries out arithmetic operations, logic operations, rotation, increment, decrement, branch decisions, etc. the internal data path is simplifed by moving data through the accumulator and the alu. certain internal registers are implemented in the data memory and can be directly or indirectly addressed. the simple addressing methods of these registers along with additional architectural features ensure that a minimum of external components is required to provide a functional i/o and a/d control system with maximum reliability and flexibility. this makes the device suitable for low-cost, high-volume production for controller applications. clocking and pipelining the main system clock, derived from hxt, lxt, hirc, or erc oscillator is subdivided into four internally generated non-overlapping clocks, t1~t4. the program counter is incremented at the beginning of the t1 clock during which time a new instruction is fetched. the remaining t2~t4 clocks carry out the decoding and execution functions. in this way, one t1~t4 clock cycle forms one instruction cycle. although the fetching and execution of instructions takes place in consecutive instruction cycles, the pipelining structure of the microcontroller ensures that instructions are effectively executed in one instruction cycle. the exception to this are instructions where the contents of the program counter are changed, such as subroutine calls or jumps, in which case the instruction will take one more instruction cycle to execute. for instructions involving branches, such as jump or call instructions, two instruction cycles are required to complete instruction execution. an extra cycle is required as the program takes one cycle to frstly obtain the actual jump or call address and then another cycle to actually execute the branch. the requirement for this extra cycle should be taken into account by programmers in timing sensitive applications.
rev. 1.00 14 ????st 1?? ? 011 rev. 1.00 15 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu                                                        
                ?                  ?       ? ? ? ? ? ? system clocking and pipelining                             
      ? ? ? ?     ?  ? ? ?   ?                                  ? instruction fetching program counter C pc during program execution, the program counter is used to keep track of the address of the next instruction to be executed. it is automatically incremented by one each time an instruction is executed except for instructions, such as jmp or call that demand a jump to a non-consecutive program memory address. it must be noted that only the lower 8 bits, known as the program counter low register, are directly addressable by user. when executing instructions requiring jumping to non-consecutive addresses such as a jump instruction, a subroutine call, interrupt or reset, etc, the microcontroller manages program control by loading the required address into the program counter. for conditional skip instructions, once the condition has been met, the next instruction, which has already been fetched during the present instruction execution, is discarded and a dummy cycle takes its place while the correct instruction is obtained. program counter hi?h byte of por?ram low byte of por?ram pc11~pc8 pcl7~pcl0 the lower byte of the program counter, known as the program counter low register or pcl, is available for program control and is a readable and writeable register. by transferring data directly into this register, a short program jump can be executed directly. however, as only this low byte is available for manipulation, the jumps are limited in the present page of memory, which have 256 locations. when such program jumps are executed it should also be noted that a dummy cycle will be inserted. the lower byte of the program counter is fully accessible under program control. manipulating the pcl might cause program branching, so an extra cycle is needed to pre-fetch.
rev. 1.00 14 ????st 1?? ? 011 rev. 1.00 15 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu stack this is a special part of the memory which is used to save the contents of the program counter only. the stack is organized into 6 levels and neither part of the data nor part of the program space, and is neither readable nor writeable. the activated level is indexed by the stack pointer, and is neither readable nor writeable. at a subroutine call or interrupt acknowledge signal, the contents of the program counter are pushed onto the stack. at the end of a subroutine or an interrupt routine, signaled by a return instruction, ret or reti, the program counter is restored to its previous value from the stack. after a device reset, the stack pointer will point to the top of the stack. 6 if the stack is full and an enabled interrupt takes place, the interrupt request fag will be recorded but the acknowledge signal will be inhibited. when the stack pointer is decremented, by ret or reti, the interrupt will be serviced. this feature prevents stack overfow allowing the programmer to use the structure more easily. however, when the stack is full, a call subroutine instruction can still be executed which will result in a stack overfow. precautions should be taken to avoid such cases which might cause unpredictable program branching. if the stack is overfow, the frst program counter save in the stack will be lost. arithmetic and logic unit C alu the arithmetic-logic unit or alu is a critical area of the microcontroller that carries out arithmetic and logic operations of the instruction set. connected to the main microcontroller data bus, the alu receives related instruction codes and performs the required arithmetic or logical operations after which the result will be placed in the specifed register. as these alu calculation or operations may result in carry, borrow or other status changes, the status register will be correspondingly updated to refect these changes. the alu supports the following functions: arithmetic operations: add, addm, adc, adcm, sub, subm, sbc, sbcm, daa logic operations: and, or, xor, andm, orm, xorm, cpl, cpla rotation rra, rr, rrca, rrc, rla, rl, rlca, rlc increment and decrement inca, inc, deca, dec branch decision, jmp, sz, sza, snz, siz, sdz, siza, sdza, call, ret, reti.
rev. 1.00 16 ????st 1?? ? 011 rev. 1.00 17 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu progam memory the program memory is the location where the user code or program is stored. the device is supplied with one-time programmable, otp, memory where users can program their application code into the device. by using the appropriate programming tools, otp device offers users the fexibility to freely develop their applications which may be useful during debug or for products requiring frequent upgrades or program changes. structure the program memory has a capacity of 4k16. the program memory is addressed by the program counter and also contains data, table information and interrupt entries information. table data, which can be setup in any location within the program memory, is addressed by separate table pointer registers. fffh 16 bits time base 1 interrupt time base 0 interrupt a/d interrupt timer 1 interrupt timer 0 interrupt multi-function interrupt reset program memory structure special vectors within the program memory, certain locations are reerved for special usage such as reset and interrupts. reset vector this vector is reserved for use by the device reset for program initialisation. after a device reset is initiated, the program will jump to this location and begin execution. external interrupt vector this vector is used by the external interrupt. if the external interrupt pin on the device receives an edge transition, the program will jump to this location and begin execution if the external interrupt is enabled anthe stack is not full. the external interrupt active edg transition type, whether high to low, low to high or both is specifed in the integ register. timer/event 0/1 counter interrupt vector this internal vector is used by the timer/event counters. if a timer/event counter overflow occurs, the program will jump to its respective location and begin execution if the associated timer/event counter interrupt is enabled and the stack is not full. time base 0/1 interrupt vector this internal vector is used by the internal time base 0/1. if a time base overfow occurs, the program will jump to this location and begin execution if the time base counter interrupt is enabled and the stack is not full.
rev. 1.00 16 ????st 1?? ? 011 rev. 1.00 17 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu look-up table any location within the program memory can be defned as a look-up table where programmers can store fxed data. to use the look-up table, the table pointer must frst be setup by placing the address of the look up data to be retrieved in the table pointer register, tblp. these registers define the total address of the look-up table. after setting up the table pointer, the table data can be retrieved from the program memory using the tabrd [m] instructions, respectively. when the instruction is executed, the lower order table byte from the program memory will be transferred to the user defned data memory register [m] as specifed in the instruction. the higher order table data byte from the program memory will be transferred to the tblh special register. any unused bits in this transferred higher order byte will be read as 0. the accompanying diagram illustrates the addressing data fow of the look-up table. pc high byte last page or present page pc11~pc8 data 16 bits program memory address register tblh high byte low byte user selected register tblp register instruction table location bits b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 t ?brdc [m] pc11 pc10 pc9 pc8 @7 @6 @5 @4 @3 @? @1 @0 t ? brdl [m] 1 1 1 1 @7 @6 @5 @4 @3 @? @1 @0 pc11~pc8: current program counter bits @7~@0: table pointer tblp bits b11~b0: table address location bits table program example the accompanying example shows how the table pointer and table data is defned and retrieved from the device. this example uses raw table data located in the last page which is stored there using the org statement. the value at this org statement is f00h which refers to the start address of the last page within the 4k program memory of the microcontroller. the table pointer is setup here to have an initial value of 06h. this will ensure that the frst data read from the data table will be at the program memory address f06h or 6 locations after the start of the last page. note that the value for the table pointer is referenced to the frst address of the present page if the tabrdc [m] instruction is being used. the high byte of the table data which in this case is equal to zero will be transferred to the tblh register automatically when the tabrdl [m] instruction is executed. because the tblh register is a read-only register and cannot be restored, care should be taken to ensure its protection if both the main routine and interrupt service routine use the table read instructions. if using the table read instructions, the interrupt service routines may change the value of tblh and subsequently cause errors if used again by the main routine. as a rule it is recommended that simultaneous use of the table read instructions should be avoided. however, in situations where simultaneous use cannot be avoided, the interrupts should be disabled prior to the execution of any main routine table-read instructions. note that all table related instructions require two instruction cycles to complete their operation.
rev. 1.00 18 ????st 1?? ? 011 rev. 1.00 19 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu table read program example: tempreg1 db ? ; temporary register #1 tempreg2 db ? ; temporary register #2 : : mov a,06h ; initialise table pointer C note that this address ; is referenced mov tblp, a ; to the last page or present page : : tabrdl tempreg1 ; transfers value in table referenced by table pointer ; to tempreg1 data at prog.memory address f06h ; transferred to to tempreg1 and tblh dec tblp ; reduce value of table pointer by one tabrdl tempreg2 ; transfers value in table referenced by table pointer ; to tempreg2 data at prog.memory address f05h ; transferred to tempreg2 and tblh in this example the ; data 1ah is transferred to tempreg1 and data 0fh ; to register tempreg2 the value 00h will be ; transferred to the high byte register tblh : : org 0f00h ; sets initial address of last page dc 00ah, 00bh, 00ch, 00dh, 00eh, 00fh, 01ah, 01bh : :
rev. 1.00 18 ????st 1?? ? 011 rev. 1.00 19 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu data memory the data memory is an 8-bit wide ram internal memory and is the location where temporary information is stored. divided into three sections, the frst of these is an area of ram where special function registers are located. these registers have fxed locations and are necessary for correct operation of the device. many of these registers can be read from and written to directly under program control, however, some remain protected from user manipulation. the second area of data memory is reserved for general purpose use. all locations within this area are read and write accessible under program control. the third area is reserved for the lcd memory. this special area of data memory is mapped directly to the lcd display so data written into this memory area will directly affect the displayed data. the addresses of the lcd memory area overlap those in the general purpose data memory area. switching between the different data memory banks is achieved by setting the bank pointer to the correct value. structure the data memory is subdivided into three banks, all of which are implemented in 8-bit wide ram. the data memory located in bank 0 is subdivided into two sections, the special purpose data memory and the general purpose data memory. the start address of the data memory is the address 00h. the lcd memory is mapped into bank 1. bank 2 contains only general purpose data memory. as the special purpose data memory registers are mapped into all bank areas, they can subsequently be accessed from any bank location. 00h ffh 3fh 40h special purpose data memory general purpose data memory bank 1 ldc memory bank 0 bank 2 data memory structure general purpose data memory all microcontroller programs require an area of read/write memory where temporary data can be stored and retrieved for use later. it is this area of ram memory that is known as general purpose data memory. this area of data memory is fully accessible by the user program for both read and write operations. by using the set [m].i and clr [m].i instructions individual bits can be set or reset under program control giving the user a large range of fexibility for bit manipulation in the data memory. for this device, the general purpose data memory, in addition to being located in bank 0, is also stored in bank 2. bank0 bank1 (lcd ram) bank2 40h~ffh 40h~56h 40h~5fh
rev. 1.00 ?0 ????st 1?? ? 011 rev. 1.00 ?1 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu display memory the data to be displayed on the lcd display is stored in an area of fully accessible data memory. by writing to this area of ram, the display output can be directly controlled by the application program. as this memory exists in bank 1, but have addresses which map into the general purpose data memory, it is necessary to frst ensure that the bank pointer is set to the value 01h before accessing the display memory. the display memory can only be accessed indirectly using the memory pointer mp1 and the indirect addressing register iar1. when the bank pointer is set to bank 1 to access the display memory, if any addresses with a value less than 40h are read, the special purpose memory in bank 0 will be accessed. also, if the bank pointer is set to bank 1, if any addresses higher than the last address in bank 1 are read, then a value of 00h will be returned. special purpose data memory this area of data memory is where registers, necessary for the correct operation of the microcontroller, are stored. most of the registers are both readable and writeable but some are protected and are readable only, the details of which are located under the relevant special function register section. note that for locations that are unused, any read instruction to these addresses will return the value 00h. acsr adcr adrh adrl pwm0 ctrl1 lcdo pwm1 lvrc ctrl0 pawk pb pbc pbpu pc pcc pcpu ancsr0 ancsr1 wdtc lvdc papu pac pa bp mfic pd intc1 tmr0c tmr1 tmr1c pfc pfpu tmr0 intc0 status ctrl4 tblh tblp pcl acc mp1 iar1 mp0 iar0 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0ah 0bh 0ch 0dh 0eh 0fh 10h 11h 12h 13h 14h 15h 16h 17h ctrl2 lcdc ctrl3 integ pf pepu pec pe pdpu pdc 26h 27h 28h 29h 2ah 2bh 2ch 2dh 2eh 2fh 30h 31h 32h 33h 34h 35h 36h 18h 19h 1ah 1bh 1ch 1dh 1eh 1fh 20h 21h 22h 23h 24h 25h 3fh special purpose data memory
rev. 1.00 ?0 ????st 1?? ? 011 rev. 1.00 ?1 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu special function register most of the special function register details will be described in the relevant functional section. however several registers require a separate description in this section. indirect addressing registers C iar0, iar1 the indirect addressing registers, iar0 and iar1, although having their locations in normal ram register, do not actually physically exist as normal registers. the method of indirect addressing for ram data manipulation is using these indirect addressing registers and memory pointers, in contrast to direct memory addressing, where the actual memory address is specifed. actions on the iar0 and iar1 registers will result in no actual read or write operation to these registers but rather to the memory location specifed by their corresponding memory p ointers, mp0 or mp1. acting as a pair, iar0 and mp0 can together access data from bank0 while the iar1 and mp1 register pair can access data from any bank. as the indirect addressing registers are not physically implemented, reading the indirect addressing registers indirectly will return a result of 00h and writing to the registers indirectly will result in no operation. memory pointers C mp0, mp1 two memory pointers, known as mp0 and mp1 are provided. these memory pointers are physically implemented in the data memory and can be manipulated in the same way as normal registers providing a convenient way with which to indirectly address and track data. mp0 can only be used to indirectly address data in bank 0 while mp1 can be used to address data in bank 0, bank 1 and bank 2. when any operation to the relevant indirect addressing registers is carried out, the actual address that the microcontroller is directed to, it is the address specifed by the related memory pointer. indirect addressing program example data . section data adres1 db ? adres2 db ? adres3 db ? adres4 db ? block db ? code. section at 0 code org 00h start: mov a,04h ;setup size of block mov block,a mov a,offset adres1 ; accumulator loaded with frst ram address mov mp0,a ; setup memory pointer with frst ram address loop: clr iar0 ; clear the data at address defned by mp0 inc mp0 ; increment memory pointer sdz block ; check if last memory location has been cleared jmp loop continue: the important point to note here is that in the example shown a bove, no reference is made to specifc data memory addresses.
rev. 1.00 ?? ????st 1?? ? 011 rev. 1.00 ?3 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu accumulator C acc the accumulator is central to the operation of any microcontroller and is closely related with operations carried out by the alu. the accumulator is the place where all intermediate results from the alu are stored. without the accumulator it would be necessary to write the result of each calculation or logical operation such as addition, subtraction, shift, etc., to the data memory resulting in higher programming and timing overheads. data transfer operations usually involve the temporary storage function of the accumulator; for example, when transferring data between one user-defined register and another, it is necessary to do this by passing the data through the accumulator as no direct transfer between two registers is permitted. bank pointer C bp the data memory is divided into three banks, known as bank 0, bank1 and bank 2. a bank pointer, which is bit 0~1 of the bank pointer register is used to select the required data memory bank. only data in bank 0 can be directly addressed as data in bank 1 and bank2 must be indirectly addressed using memory pointer mp1 and indirect addressing register iar1. using memory pointer mp0 and indirect addressing register iar0 will always access data from bank 0, irrespective of the value of the bank pointer. memory pointer mp1 and indirect addressing register iar1 can indirectly address data in bank 0, bank 1, or bank 2 depending upon the value of the bank pointer. the data memory is initialised to bank 0 after a reset, except for the wdt time-out reset in the idle/sleep mode, in which case, the data memory bank remains unaffected. it should be noted that special function data memory is not affected by the bank selection, which means that the special function registers can be accessed from bank 0, bank1 or bank 2. directly addressing the data memory will always result in bank 0 being accessed irrespective of the value of the bank pointer. bp register bit 7 6 5 4 3 2 1 0 name dmbp1 dmbp0 r/w r/w r/w por 0 0 bit 7~2 unimplemented, read as 0 bit 1~0 dmbp1, dmbp0: data memory bank point 00: bank 0 01: bank 1 10: bank 2 11: undefned program counter low register C pcl to provide additional program control functions, the low byte of the program counter is made accessible to programmers by locating it within the special purpose area of the data memory. by manipulating this register, direct jumps to other program locations are easily implemented. loading a value directly into this pcl register will cause a jump to the specifed program memory location, however as the register is only 8-bit wide only jumps within the current program memory page are permitted. when such operations are used, note that a dummy cycle will be inserted.
rev. 1.00 ?? ????st 1?? ? 011 rev. 1.00 ?3 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu look-up table registers C tblp, tblh these three special function registers are used to control operation of the look-up table which is stored in the program memory. tblp is the table pointer and indicates the location where the table data is located. their value must be setup before any table read commands are executed. their value can be changed, for example using the inc or dec instructions, allowing for easy table data pointing and reading. tblh is the location where the high order byte of the table data is stored after a table read data instruction has been executed. note that the lower order table data byte is transferred to a user defned location. status register C status this 8-bit register contains the zero fag (z), carry fag (c), auxiliary carry fag (ac), overfow fag (ov), power down fag (pdf), and watchdog time-out fag (to). these arithmetic/logical operation and system management fags are used to record the status and operation of the microcontroller . with the exception of the to and pdf fags, bits in the status register can be altered by instructions like most other registers. any data written into the status register will not change the to or pdf fag. in addition, operations related to the status register may give different results due to the different instruction operations. the to fag can be affected only by a system power-up, a wdt time-out or by executing the clr wdt or halt instruction. the pdf fag is affected only by executing the halt or clr wdt instruction or during a system power-up. the z, ov, ac and c fags generally refect the status of the latest operations. in addition, on entering an interrupt sequence or executing a subroutine call, the status register will not be pushed onto the stack automatically. if the contents of the status registers are important and if the subroutine can corrupt the status register, precautions must be taken to correctly save it. note that bits 0~3 of the status register are both readable and writeable bits. status register bit 7 6 5 4 3 2 1 0 name to pdf ov z ?c c r/w r/w r/w r/w r/w r/w r/w por 0 0 x x x x x ?nknown bit 7~6 unimplemented, read as 0 bit 5 to: watchdog time-out fag 0: after power up or executing the clr wdt or halt instruction 1: a watchdog time-out occurred bit 4 pdf: power down fag 0: after power up or executing the clr wdt instruction 1: by executing the halt instruction bit 3 ov: overfow fag 0: no overfow 1: an operation results in a carry into the highest-order bit but not a carry out of the highest-order bit or vice versa bit 2 z: zero fag 0: the result of an arithmetic or logical operation is not zero 1: the result of an arithmetic or logical operation is zero
rev. 1.00 ?4 ????st 1?? ? 011 rev. 1.00 ?5 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu bit 1 ac: auxiliary fag 0: no auxiliary carry 1: an operation results in a carry out of the low nibbles in addition, or no borrow from the high nibble into the low nibble in subtraction bit 0 c: carry fag 0: no carry-out 1: an operation results in a carry during an addition operation or if a borrowing does not take place during a subtraction operation c is also affected by a rotate through carry instruction system control registers C ctrl0, ctrl1, ctrl2, ctrl3, ctrl4 these registers are used to provide control over various internal functions. some of these include the pfd control, pwm control, certain system clock options, the lxt oscillator low power control, buzzer function control, lcd driver clock selection, timer clock source selection, time base functions division ratio, and the lxt oscillator enable control. ctrl0 register bit 7 6 5 4 3 2 1 0 name pcfg pfdcs pwmsel pwmc1 pwmc0 pfdc clkmod r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 bit 7 pcfg: pa2~pa1 pin-shared function pin remapping control 0: tc1/tc0 pin-shared with pa1/pa2 1: tc1/tc0 pin-shared with pa2/pa1 bit 6 pfdcs : pfd clock source 0: timer0 1: timer1 bit 5 pwmsel: pwm type selection 0: 6+2 1: 7+1 this bit can be clear to 0, but can not set to 1. bit 4 pwmc1: i/o or pwm1 0: i/o 1: pwm1 bit 3 pwmc0: i/o or pwm0 0: i/o 1: pwm0 bit 2 pfdc: i/o or pfd 0: i/o 1: pfd bit 1 unimplemented, read as 0 bit 0 clkmod: system clock mode selection 0: high speed C hirc used as system clock 1: low speed C lxt used as system clock, hirc oscillator stopped
rev. 1.00 ?4 ????st 1?? ? 011 rev. 1.00 ?5 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu ctrl1 register bit 7 6 5 4 3 2 1 0 name t0s1 t0s0 tb01 tb00 r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~6 t0s1, t0s0: prescaler/tmr0 clock source 00: f tp =f sys prescaler clock source is f sys tmr0 clock source is come from the output clock of prescaler 01: f tp =lxt prescaler clock source is lxt tmr0 clock source is come from the output clock of prescaler 10: f tp =pfd0 prescaler clock source is pfd0 tmr0 clock source is come from f sys 11: undefned note: if pwm0c or pwm1c is enabled, the clock source of prescaler is only selected from f sys or pfd0 by assigning t0s1. bit 5~4 tb01 , tb00 : time base 0 period selection 00: f s /2 12 01: f s /2 13 10: f s /2 14 11: f s /2 15 bit 3~0 unimplemented, read as 0 ctrl2 register bit 7 6 5 4 3 2 1 0 name lcdsel? lcdsel1 lcdsel0 bzsel? bzsel1 bzsel0 buzc lxten r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 1 bit 7~5 lcdsel2~lcdsel0 : lcd driver clock selection 000: f s /2 2 001: f s /2 3 010: f s /2 4 011: f s /2 5 100: f s /2 6 101: f s /2 7 110: f s /2 8 111: reserved bit 4~2 bzsel2~bzsel0 : bz frequency selection 000: f s /2 2 001: f s /2 3 010: f s /2 4 011: f s /2 5 100: f s /2 6 101: f s /2 7 110: f s /2 8 111 : f s /2 9 bit 1 buzc : i/o, buz selection 0: i/o 1: buz
rev. 1.00 ?6 ????st 1?? ? 011 rev. 1.00 ?7 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu bit 0 lxten: lxt oscillator on/off control after execution of halt instruction 0: lxt off in sleep mode 1: lxt on in idle mode ctrl3 register bit 7 6 5 4 3 2 1 0 name lvrf lrf wrf r/w r/w r/w r/w por x 0 0 "x" ?nknown bit 7~3 unimplemented, read as 0 bit 2 lvrf: reset caused by lvr function activation 0: not active 1: active this bit can be clear to 0, but can not set to 1. bit 1 lrf: reset caused by lvrc setting 0: not active 1: active this bit can be clear to 0, but can not set to 1. bit 0 wrf: reset caused by we[4:0] setting 0: not active 1: active this bit can be clear to 0, but can not set to 1. ctrl4 register bit 7 6 5 4 3 2 1 0 name lxtlp tb1? tb11 tb10 r/w r/w r/w r/w r/w por 0 1 1 1 bit 7~5,3 undefned, read as 0 bit 4 lxtlp: lxt oscillator low power control function 0: lxt oscillator quick start-up mode 1: lxt oscillator low power mode bit 2~0 tb12~tb10: time base 1 clock selection 000: f s /2 8 001: f s /2 9 010: f s /2 10 011: f s /2 11 100: f s /2 12 101: f s /2 13 110: f s /2 14 111: f s /2 15
rev. 1.00 ?6 ????st 1?? ? 011 rev. 1.00 ?7 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu oscillator various oscillator options offer the user a wide range of functions according to their various application requirements. the flexible features of the oscillator functions ensure that the best optimisation can be achieved in terms of speed and power saving. oscillator overview in addition to being the source of the main system clock the oscillators also provide clock sources for the watchdog timer and time base functions. external oscillators requiring some external components as well as fully integrated internal oscillators, requiring no external components, are provided to form a wide range of both fast and slow system oscillators. all oscillator options are selected through the configuration options. the higher frequency oscillators provide higher performance but carry with it the disadvantage of higher power requirements, while the opposite is of course true for the lower frequency oscillators. with the capability of dynamically switching between fast and slow system clock, the device has the fexibili ty to optimize the performance/power ratio, a feature especially important in power sensitive portable applications. type name freq. pins external crystal hxt 400 k hz~1?mhz osc1/osc? external rc erc 400 k hz~1?mhz osc1 internal hi?h speed rc hirc 4? 8 or 1?mhz external low speed rc lxt 3?768hz xt1/xt? internal low speed rc lirc 3? k hz oscillator types system clock confgurations there are fve system oscillators, three high speed oscillators and two low speed oscillators. the high speed oscillators are the external crystal/ceramic oscillator C hxt, the external C erc, and the internal rc oscillator C hirc. the one low speed oscillator is the external 32768hz oscillator C lxt and the internal 32khz (v dd =5v) oscillator C lirc. external crystal/resonator oscillator C hxt the simple connection of a crystal across osc1 and osc2 will create the necessary phase shift and feedback for oscillation. however, for some crystals and most resonator types, to ensure oscillation and accurate frequency generation, it is necessary to add two small value external capacitors, c1 and c2. the exact values of c1 and c2 should be selected in consultation with the crystal or resonator manufacturers specifcation.                               
                                        ?      ?                 ? ?  crystal/resonator oscillator C hxt
rev. 1.00 ?8 ????st 1?? ? 011 rev. 1.00 ?9 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu external rc oscillator C erc using the erc oscillator only requires that a resistor, with a value between 24k and 1.5m, is connected between osc1 and vdd, and a capacitor is connected between osc and ground, providing a low cost oscillator configuration. it is only the external resistor that determines the oscillation frequency; the external capacitor has no infuence over the frequency and is connected for stability purposes only. device trimming during the manufacturing process and the inclusion of internal frequency compensation circuits are used to ensure that the infuence of the power supply voltage, temperature and process variations on the oscillation frequency are minimised. here only the osc1 pin is used and leaving osc2 as a general i/o port.               external rc oscillator C erc internal rc oscillator C hirc the internal rc oscillator is a fully integrated system oscillator requiring no external components. the internal rc oscillator has three fxed frequencies of either 4mhz, 8mhz or 12mhz. device trimming during the manufacturing process and the inclusion of internal frequency compensation circuits are used to ensure that the infuence of the power supply voltage, temperature and process variations on the oscillation frequency are minimised. note that if this internal system clock option is selected, as it requires no external pins for its operation. internal rc oscillator pa5/osc2 pa6/osc1 internal rc oscillator C hirc external 32768hz crystal oscillator C lxt when the microcontroller enters the idle/sleep mode, the system clock is switched off to stop microcontroller activity and to conserve power. however, in many microcontroller applications it may be necessary to keep the internal timers operational even when the microcontroller is in the power-down mode. to do this, another clock, independent of the system clock, must be provided. to do this a confguration option exists to allow a high speed oscillator to be used in conjunction with a low speed oscillator, known as the lxt oscillator. the lxt oscillator is implemented using a 32768hz crystal connected to pins xt1/xt2. however, for some crystals, to ensure oscillation and accurate frequency generation, it is necessary to add two small value external capacitors, c1 and c2. the exact values of c1 and c2 should be selected in consultation with the crystal or resonator manufacturers specification. the external parallel feedback resistor, rp, is required. the lxt oscillator must be used together with the hxt, erc or hirc register.
rev. 1.00 ?8 ????st 1?? ? 011 rev. 1.00 ?9 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu                               
                                           ?      ?     ??? ?- external lxt oscillator C lxt lxt oscillator c1 and c2 values crystal freq?ency c1 c? 3?768hz 8pf 10pf note: 1. c1 and c? val?es are for ?? idance only. ?. r p =5m ~10m is recommended. a confguration option determines if the xt1/xt2 pins are used for the lxt oscillator or as i/o pins. if the i/o option is selected then the xt1/xt2 pins can be used as normal i/o pins. if the lxt oscillator is selected then the 32khz crystal should be connected to the xt1/xt2 pins. lxt oscillator low power function the lxt oscillator can function in one of two modes, the quick start mode and the low power mode. the mode selection is executed using the lxtlp bit in the ctrl4 register. lxtlp bit lxt mode 0 q?ick start 1 low-power after power on the lxtlp bit, it will be automatically cleared to zero ensuring that the lxt oscillator is in the quick start operating mode. in the quick start mode the lxt oscillator will power up and stabilise quickly. however, after the lxt oscillator has fully powered up it can be placed into the low-power mode by setting the lxtlp bit high. the oscillator will continue to run but with reduced current consumption, as the higher current consumption is only required during the lxt oscillator start-up. in power sensitive applications, such as battery applications, where power consumption must be kept to a minimum, it is therefore recommended that the application program sets the lxtlp bit high about 2 seconds after power-on. it should be noted that, no matter what condition the lxtlp bit is set to, the lxt oscillator will be always function normally, the only difference is that it will take more time to start up if it is in the low-power mode. internal low speed oscillator C lirc the lirc is a fully self-contained free running on-chip rc oscillator with a typical frequency of 32khz at 5v requiring no external components. when the device enters the idle/sleep mode, the system clock will stop running but the wdt oscillator continues to free-run and to keep the watchdog active. if lvr is enabled or wdt is enabled or f s clock source is lirc, lirc oscillator is turn on. on the contrary, lirc oscillator is turn off if lvr is disabled and wdt is disabled and f s clock source is lxt or f sys/ 4.
rev. 1.00 30 ????st 1?? ? 011 rev. 1.00 31 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu operating modes by using the lxt low frequency oscillator in combination with a high frequency oscillator, the system can be selected to operate in a number of different modes. these modes are normal, slow, idle and sleep. mode types and selection the higher frequency oscillators provide higher performance but carry with it the disadvantage of higher power requirements, while the opposite is of course true for the lower frequency oscillators. with the capability of dynamically switching between fast and slow oscillators, the device has the fexibility to optimise the performance/power ratio, a feature especially important in power sensitive portable applications. for the device the lxt oscillator can run together with any of the high speed oscillators, namely the hxt, erc or the hirc. the clkmod bit in the ctrl0 register can be used to switch the system clock from the selected high speed oscillator to the low speed lxt oscillator. when the halt instruction is executed the lxt oscillator can be chosen to run or not using the lxten bit in the ctrl2 register. hxt erc hirc lxt lirc f hxt f erc f hirc f lxt f sys f lirc configuration option clkmod (normal or slow mode select) (normal) (slow) mux to watchdog timer mux system clock confgurations when the system enters the sleep or idle mode, the high frequency system clock will always stop running. the accompanying table shows the relationship between the clkmod bit, the halt instruction and the high/low frequency oscillators. the clmod bit can change normal or slow mode. operating mode control operating mode osc1/osc2 confguration xt1/xt2 confguration hxt erc hirc lxt lxten=0 lxten=1 normal on on on on on slow off off off on on idle off off off off on sleep off off off off off
rev. 1.00 30 ????st 1?? ? 011 rev. 1.00 31 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu mode switching the device is switched between one mode and another using a combination of the clkmod bit in the ctrl0 register and the halt instruction. the clkmod bit chooses whether the system runs in either the normal or slow mode by selecting the system clock to be sourced from either a high or low frequency oscillator. the halt instruction forces the system into either the idle or sleep mode, depending upon whether the lxt oscillator is running or not. the halt instruction operates independently of the clkmod bit condition. when a halt instruction is executed and the lxt oscillator is not running, the system enters the sleep mode, in which case, the following conditions exist: the system oscillator will stop running and the application program will stop at the halt instruction. the data memory contents and registers will maintain their present condition. the wdt will be cleared and resume counting. the i/o ports will maintain their present condition. in the status register, the power down fag, pdf, will be set and the watchdog time-out fag, to, will be cleared. standby current considerations as the main reason for entering the idle/sleep mode is to keep the current consumption of the mcu to as low a value as possible, perhaps only in the order of several micro-amps, there are other considerations which must also be taken into account by the circuit designer if the power consumption is to be minimised. special attention must be made to the i/o pins on the device. all high-impedance input pins must be connected to either a fxed high or low level as any foating input pins could create internal oscillations and result in increased current consumption. care must also be taken with the loads, which are connected to i/o pins, which are setup as outputs. these should be placed in a condition in which minimum current is drawn or connected only to external circuits that do not draw current, such as other cmos inputs. if the confguration options have enabled the watchdog timer internal oscillator lirc then this will continue to run when in the idle/sleep mode and will thus consume some power. for power sensitive applications it may be therefore preferable to use the system clock source for the watchdog timer. the lxt, if confgured for use, will also consume a limited amount of power, as it continues to run when the device enters the idle/sleep mode. to keep the lxt power consumption to a minimum level the lxtlp bit in the ctrl4 register, which controls the low power function, should be set high. wake-up after the system enters the idle/sleep mode, it can be woken up from one of various sources listed as follows: power-on reset an external falling edge on pa0 to pa7 a system interrupt a wdt overfow if the system is woken up by power-on reset, the device will experience a full system reset, however, if the device is woken up by a wdt overfow, a watchdog timer reset will be initiated. although both of these wake-up methods will initiate a reset operation, the actual source of the wake-up can be determined by examining the to and pdf fags. the pdf fag is cleared by a system power-up or executing the clear watchdog timer instructions and is set when executing the halt instruction. the to fag is set if a wdt time-out occurs, and causes a wake-up that only resets the program
rev. 1.00 3? ????st 1?? ? 011 rev. 1.00 33 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu counter and stack pointer, the other fags remain in their original status. pins pa0 to pa7 can be setup via the pawk register to permit a negative transition on the pin to wake-up the system. when a pa0 to pa7 pin wake-up occurs, the program will resume execution at the instruction following the halt instruction. if the system is woken up by an interrupt, then two possible situations may occur. the frst is where the related interrupt is disabled or the interrupt is enabled but the stack is full, in which case the program will resume execution at the instruction following the halt instruction. in this situation, the interrupt which wake-up the device will not be immediately serviced, but will rather be serviced later when the related interrupt is finally enabled or when a stack level becomes free. the other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. if an interrupt request fag is set to 1 before entering the idle/sleep mode, then any future interrupt requests will not generate a wake-up function of the related interrupt will be ignored. no matter what the source of the wake-up event is, once a wake-up event occurs, there will be a time delay before normal program execution resumes. consult the table for the related time. wake-up source oscillator type erc, irc crystal clkmod=1 lxten=0 clkmod=1 lxten=1 power on reset/lvr t rsdt +t sst1 t rsdt +t sst? p ? port t sst1 t sst? t sst? t sst1 interr?pt wdt overfow wake-up delay time note: 1. t rstd (reset delay time), t sys (system clock) 2. t rstd is power-on delay, typical time=50ms 3. t sst1 =2t sys 4. t sst2 =128t sys
rev. 1.00 3? ????st 1?? ? 011 rev. 1.00 33 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu watchdog timer the watchdog timer is provided to prevent program malfunctions or sequences from jumping to unknown locations, due to certain uncontrollable external events such as electrical noise. watchdog timer clock source the watchdog timer clock source is provided by the internal clock, f s , which is in turn supplied by the lirc oscillator. the lirc internal oscillator has an approximate period of 32khz at a supply voltage of 5v. however, it should be noted that this specifed internal clock period can vary with vdd, temperature and process variations. the watchdog timer source clock is then subdivided by a ratio of 2 8 to 2 18 to give longer timeouts, the actual value being chosen using the ws2~ws0 bits in the wdtc register. watchdog timer control register a single register, wdtc, controls the required timeout period as well as the enable/disable operation. this register together with the corresponding configuration option control the overall operation of the watchdog timer. wdtc register bit 7 6 5 4 3 2 1 0 name we4 we3 we? we1 we0 ws? ws1 ws0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 1 0 1 0 0 1 1 bit 7~3 we4~we0 : wdt function software control if the wdt confguration option is always enable: 10101 or 01010: enabled other: reset mcu if the wdt confguration option is controlled by the wdt control register: 10101: disabled 01010: enabled other: reset mcu when these bits are changed by the environmental noise to reset the microcontroller, the reset operation will be activated after 2~3 lirc clock cycles and the wrf bit in the ctrl3 register will be set to 1. bit 2~0 ws2~ws0 : wdt time-out period selection 000: 2 8 /f s 001: 2 10 /f s 010: 2 12 /f s 011: 2 14 /f s 100: 2 15 /f s 101: 2 16 /f s 110: 2 17 /f s 111: 2 18 /f s
rev. 1.00 34 ????st 1?? ? 011 rev. 1.00 35 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu ctrl3 register bit 7 6 5 4 3 2 1 0 name lvrf lrf wrf r/w r/w r/w r/w por x 0 0 bit 7~3 : unimplemented, read as 0 bit 2 lvrf : lvr function reset fag describe elsewhere. bit 1 lrf : lvr control register software reset fag describe elsewhere. bit 0 wrf : wdt control register software reset fag 0: not occur 1: occurred this bit is set to 1 by the wdt control register software reset and cleared by the application program. note that this bit can only be cleared to 0 by the application program. watchdog timer operation the watchdog timer operates by providing a device reset when its timer overfows. this means that in the application program and during normal operation the user has to strategically clear the watchdog timer before it overfows to prevent the watchdog timer from executing a reset. this is done using the clear watchdog instructions. if the program malfunctions for whatever reason, jumps to an unknown location, or enters an endless loop, these clear instructions will not be executed in the correct manner, in which case the watchdog timer will overfow and reset the device. some of the watchdog timer options, such as always on select and clear instruction type are selected using configuration options. with regard to the watchdog timer enable/disable function, there are also five bits, we4~we0, in the wdtc register to offer additional enable/disable and reset control of the watchdog timer. if the wdt configuration option is determined that the wdt function is always enabled, the we4~we0 bits still have effects on the wdt function. when the we4~we0 bits value is equal to 01010b or 10101b, the wdt function is enabled. however, if the we4~we0 bits are changed to any other values except 01010b and 10101b, which is caused by the environmental noise, it will reset the microcontroller after 2~3 lirc clock cycles. if the wdt confguration option is determined that the wdt function is controlled by the wdt control register, the we4~we0 values can determine which mode the wdt operates in. the wdt function will be disabled when the we4~we0 bits are set to a value of 10101b. the wdt function will be enabled if the we4~we0 bits value is equal to 01010b. if the we4~we0 bits are set to any other values by the environmental noise, except 01010b and 10101b, it will reset the device after 2~3 lirc clock cycles. after power on these bits will have the value of 01010b. watchdog timer enable/disable control wdt confguration option we4 ~ we0 bits wdt function ?lways enable 01010b or 10101b enable ?ny other val?e reset mcu controlled by wdt control re?ister 10101b disable 01010b enable ?ny other val?e reset mcu under normal program operation, a watchdog timer time-out will initialise a device reset and set the status bit to. however, if the system is in the sleep or idle mode, when a watchdog timer
rev. 1.00 34 ????st 1?? ? 011 rev. 1.00 35 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu time-out occurs, the to bit in the status register will be set and only the program counter and stack pointer will be reset. three methods can be adopted to clear the contents of the watchdog timer. the frst is a wdt reset, which means a certain value except 01010b and 10101b written into the we4~we0 bit fled, the second is using the watchdog timer software clear instructions and the third is via a halt instruction. there is only one method of using software instruction to clear the watchdog timer. that is to use the single clr wdt instruction to clear the wdt. the maximum time out period is when the 2 18 division ratio is selected. as an example, with a 32 khz lirc oscillator as its source clock, this will give a maximum watchdog period of around 8 second for the 2 18 division ratio, and a minimum timeout of 7.8ms for the 2 8 division ration. clr wdtinstr?ction 8-sta?e divider wdt prescaler we4~we0 bits wdtc re?ister reset mcu lirc f s f lirc f s /? 8 8-to-1 mux clr ws?~ws0 (f s /? 8 ~ f s /? 18 ) wdt time-o?t (? 8 /f s ~ ? 18 /f s ) watchdog timer
rev. 1.00 36 ????st 1?? ? 011 rev. 1.00 37 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu reset and initialisation a reset function is a fundamental part of any microcontroller ensuring that the device can be set to some predetermined condition irrespective of outside parameters . the most important reset condition is after power is frst applied to the microcontroller. in this case, internal circuitry will ensure that the microcontroller, after a short delay, will be in a well defned state and ready to execute the frst program instruction. after this power-on reset, certain important internal registers will be set to defned states before the program commences. another type of reset is when the watchdog timer overflows and resets the microcontroller. all types of reset operations result in different register conditions being setup. another reset exists in the form of a low voltage reset, lvr, where a full reset, is implemented in situations where the power supply voltage falls below a certain threshold. reset functions there are four ways in which a microcontroller reset can occur, through events occurring both internally and externally: power-on reset the most fundamental and unavoidable reset is the one that occurs after power is frst applied to the microcontroller. as well as ensuring that the program memory begins execution from the frst memory address, a power-on reset also ensures that certain other registers are preset to known conditions. all the i/o port and port control registers will power up in a high condition ensuring that all pins will be frst set to inputs. the microcontroller has an internal rc reset function, due to unstable power on conditions. this time delay created by the rc network ensures the state of the por remains low for an extended period while the power supply stabilizes. during this time, normal operation of the microcontroller is inhibited. after the state of the por reaches a certain voltage value, the reset delay time t por is invoked to provide an extra delay time after which the microcontroller can begin normal operation. vdd power-on reset sst time-out t rstd power-on reset timing chart low voltage reset C lvr the microcontroller contains a low voltage reset circuit in order to monitor the supply voltage of the device. the lvr function is always enabled with a specifc lvr voltage v lvr . if the supply voltage of the device drops to within a range of 0.9v~v lvr such as might occur when changing the battery, the lvr will automatically reset the device internally and the lvrf bit in the ctrl3 register will also be set to 1. for a valid lvr signal, a low supply voltage, i.e., a voltage in the range between 0.9v~vlvr must exist for a time greater than that specifed by t lvr in the a.c. characteristics. if the low supply voltage state does not exceed this value, the lvr will ignore the low supply voltage and will not perform a reset function. the actual v lvr value can be selected by the lvs bits in the lvrc register. if the lvs7~lvs0 bits are changed to some certain values by the environmental noise, the lvr will reset the device after 2~3 lirc clock cycles. when this happens, the lrf bit in the ctrl3 register will be set to 1. after power on the register will
rev. 1.00 36 ????st 1?? ? 011 rev. 1.00 37 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu have the value of 01010101b. note that the lvr function will be automatically disabled when the device enters power down mode.                 low voltage reset timing chart lvrc register bit 7 6 5 4 3 2 1 0 name lvs7 lvs6 lvs5 lvs4 lvs3 lvs ? lvs1 lvs0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 1 0 1 0 1 0 1 bit 7~0 lvs7~lvs0 : lvr voltage select control 01010101: 2.1v 00110011: 2.55v 10011001: 3.15v 10101010: 3.8v any other value: generates mcu reset C register is reset to por value when an actual low voltage condition occurs, as specifed by one of the four defned lvr voltage values above, an mcu reset will be generated. the reset operation will be activated after 2~3 lirc clock cycles. in this situation the register contents will remain the same after such a reset occurs. any register value, other than the four defned lvr values above, will also result in the generation of an mcu reset. the reset operation will be activated after 2~3 lirc clock cycles. however in this situation the register contents will be reset to the por value. ctrl3 register bit 7 6 5 4 3 2 1 0 name lvrf lrf wrf r/w r/w r/w r/w por x 0 0 bit 7~3 : unimplemented, read as 0 bit 2 lvrf : lvr function reset fag 0: not occur 1: occurred this bit is set to 1 when a specifc low voltage reset situation condition occurs. this bit can only be cleared to 0 by the application program. bit 1 lrf : lvr control register software reset fag 0: not occur 1: occurred this bit is set to 1 if the lvrc register contains any non defned lvr voltage register values. this in effect acts like a software reset function. this bit can only be cleared to 0 by the application program. bit 0 wrf : wdt control register software reset fag describe elsewhere.
rev. 1.00 38 ????st 1?? ? 011 rev. 1.00 39 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu watchdog time-out reset during normal operation the watchdog time-out reset during normal operation is the same as a hardware power-on reset except that the watchdog time-out fag to will be set to high.                     wdt time-out reset during normal operation timing chart watchdog time-out reset during sleep or idle mode the watchdog time-out reset during sleep or idle mode is a little different from other kinds of reset. most of the conditions remain unchanged except that the program counter and the stack pointer will be cleared to 0 and the to fag will be set to 1. refer to the a.c. characteristics for t sst details.                wdt time-out reset during sleep or idle timing chart note: the t sst is 2 clock cycles if the system clock source is provided by erc or hirc. the t sst is 128 clock for hxt or lxt. the t sst is 128 clock for lirc.
rev. 1.00 38 ????st 1?? ? 011 rev. 1.00 39 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu reset initial conditions the different types of reset described affect the reset fags in different ways. these fags, known as pdf and to are located in the status register and are controlled by various microcontroller operations, such as the sleep or idle mode function or watchdog timer. the reset flags are shown in the table: to pdf reset conditions 0 0 power-on reset ? ? lvr reset d ?rin? norm? l or slow mode operation 1 ? wdt time-o ?t reset d?rin? norm? l or slow mode operation 1 1 wdt time-o ?t reset d?rin? idle or sleep mode operation ? ?nchan?ed the following table indicates the way in which the various components of the microcontroller are affected after a power-on reset occurs. item condition after reset pro?ram co?nter reset to zero interr?pts ?ll interr?pts will be disabled prescaler ? divider cleared wdt ? time base clear after reset? wdt be?ins co?ntin? timer/event co ?nter timer co ?nter will be t? rned off inp?t/o?tp?t ports i/o ports will be set?p as inp?ts? and ?n0~? n11 as ?/d inp?t pins stack pointer stack pointer will point to the top of the stack the different kinds of resets all affect the internal registers of the microcontroller in different ways. to ensure reliable continuation of normal program execution after a reset occurs, it is important to know what condition the microcontroller is in after a particular reset occurs. the following table describes how each type of reset affects the microcontroller internal registers. register power-on reset lvr reset wdt time-out (normal operation) wdt time-out (idle/sleep) pcl 0000 0000 0000 0000 0000 0000 0000 0000 mp0 xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? mp1 xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? bp ---- --00 ---- --00 ---- --00 ---- -- ?? ?cc xxxx xxxx ???? ???? ???? ???? ???? ???? tblp xxxx xxxx ???? ???? ???? ???? ???? ???? tblh xxxx xxxx ???? ???? ???? ???? ???? ???? wdtc 0101 0011 0101 0011 0101 0011 ???? ???? st ? tus --00 xxxx -- ?? ???? --1 ? ???? --1 1 ???? intc0 -000 0000 -000 0000 -000 0000 -??? ???? intc1 -000 -000 -000 -000 -000 0000 -??? -??? tmr0 xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? tmr0c 00-0 1000 00-0 1000 00-0 1000 ???? ???? tmr1 xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? tmr1c 0000 1--- 0000 1--- 0000 1--- ???? ?--- ctrl4 ---0 -111 ---0 -111 ---0 -111 ---? -??? p? 1111 1111 1111 1111 1111 1111 ???? ???? p? c 1111 1111 1111 1111 1111 1111 ???? ???? p? wk 0000 0000 0000 0000 0000 0000 ???? ???? p ?pu -000 0000 -000 0000 -000 0000 -??? ????
rev. 1.00 40 ????st 1?? ? 011 rev. 1.00 41 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu register power-on reset lvr reset wdt time-out (normal operation) wdt time-out (idle/sleep) (normal operation) wdt time-o ?t 1111 1111 1111 1111 ???? ???? (idle/sleep) 1111 1111 1111 1111 1111 1111 ???? ???? pbpu 0000 0000 0000 0000 0000 0000 ???? ???? pc 1111 1111 1111 1111 1111 1111 ???? ???? pcc 1111 1111 1111 1111 1111 1111 ???? ???? pcpu 0000 0000 0000 0000 0000 0000 ???? ???? pd 1111 1111 1111 1111 1111 1111 ???? ???? pdc 1111 1111 1111 1111 1111 1111 ???? ???? pdpu 0000 0000 0000 0000 0000 0000 ???? ???? pe -111 1111 -111 1111 -111 1111 -??? ???? pec -111 1111 -111 1111 -111 1111 -??? ???? pepu -000 0000 -000 0000 -000 0000 -??? ???? pf ---- -111 ---- -111 ---- -111 ---- - ??? pfc ---- -111 ---- -111 ---- -111 ---- - ??? pfpu ---- -000 ---- -000 ---- -000 ---- - ??? ctrl0 0000 00-0 0000 00-0 0000 00-0 ???? ??-? ctrl1 0000 ---- 0000 ---- 0000 ---- ???? ---- ctrl? 0000 0001 0000 0001 0000 0001 ???? ???? ctrl3 ---- -x00 ---- - ??? ---- - ??? ---- - ??? pwm0 xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? pwm1 xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? ?ncsr0 0000 0000 0000 0000 0000 0000 ???? ???? ?ncsr1 ---- 0000 ---- 0000 ---- 0000 ???? ???? ?dcr 01-- 0000 01-- 0000 01-- 0000 ??-- ???? ?csr 11-0 -000 11-0 -000 11-0 -000 ??-? -??? ?drl xxxx ---- xxxx ---- xxxx ---- ???? ---- ?drh xxxx xxxx xxxx xxxx xxxx xxxx ???? ???? mfic 0000 0000 0000 0000 0000 0000 ???? ???? integ 1010 1010 1010 1010 1010 1010 ???? ???? lcdo ---- 0000 ---- 0000 ---- 0000 ---- ???? lcdc 0--- 0000 0--- 0000 0--- 0000 ?--- ???? lvdc --00 -000 --00 -000 --00 -000 ???? ???? lvrc 0101 0101 0101 0101 0101 0101 ???? ???? note: - not implement u means unchanged x means unknown
rev. 1.00 40 ????st 1?? ? 011 rev. 1.00 41 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu input/output ports holtek microcontrollers offer considerable fexibility on their i/o ports. most pins can have either an input or output designation under user program control. additionally, as there are pull-high resistors and wake-up software confgurations, the user is provided with an i/o structure to meet the needs of a wide range of application possibilities. for input operation, these ports are non-latching, which means the inputs must be ready at the t2 rising edge of instruction mov a, [m], where m denotes the port address. for output operation, all the data is latched and remains unchanged until the output latch is rewritten. pull-high resistors many product applications require pull-high resistors for their switch inputs usually requiring the use of an external resistor. to eliminate the need for these external resistors, all i/o pins, when confgured as an input have the capability of being connected to an internal pull-high resistor. these pull-high resistors are selected using registers papu, pbpu, etc. and are implemented using weak pmos transistors. port a wake-up the halt instruction forces the microcontroller into the sleep or idle mode which preserves power, a feature that is important for battery and other low-power applications. various methods exist to wake-up the microcontroller, one of which is to change the logic condition on one of the port a pins from high to low. after a halt instruction forces the microcontroller into entering the idle/sleep mode, the processor will remain idle or in a low-power state until the logic condition of the selected wake-up pin on port a changes from high to low. this function is especially suitable for applications that can be woken up via external switches. note that pins pa0 to pa7 can be selected individually to have this wake-up feature using an internal register known as pawk, located in the data memory. register name bit 7 6 5 4 3 2 1 0 p? wk p ? wk7 p ? wk6 p ? wk5 p ? wk4 p ? wk3 p ? wk? p ? wk1 p ? wk0 p ?pu p ?pu6 p ?pu5 p ?pu4 p ?pu3 p ?pu? p ?pu1 p ?pu0 p? c p ?c7 p ?c6 p ?c5 p ?c4 p ?c3 p ?c? p ?c1 p ?c0 pbpu pbpu7 pbpu6 pbpu5 pbpu4 pbpu3 pbpu? pbpu1 pbpu0 pbc pbc7 pbc6 pbc5 pbc4 pbc3 pbc? pbc1 pbc0 pcpu pcpu7 pcpu6 pcpu5 pcpu4 pcpu3 pcpu? pcpu1 pcpu0 pcc pcc7 pcc6 pcc5 pcc4 pcc3 pcc? pcc1 pcc0 pdpu pdpu7 pdpu6 pdpu5 pdpu4 pdpu3 pdpu? pdpu1 pdpu0 pdc pdc7 pdc6 pdc5 pdc4 pdc3 pdc? pdc1 pdc0 pepu pepu6 pepu5 pepu4 pepu3 pepu? pepu1 pepu0 pec pec6 pec5 pec4 pec3 pec? pec1 pec0 pfpu pfpu? pfpu1 pfpu0 pfc pfc? pfc1 pfc0 unimplemented, read as 0 pawkn: pa wake-up function control 0: disable 1: enable pacn/pbcn/pccn/pdcn/pecn/pfcn: i/o type selection 0: output 1: input papun/pbpun/pcpun/pdpun/pepun/pfpun: pull-high function control 0: disable 1: enable
rev. 1.00 4? ????st 1?? ? 011 rev. 1.00 43 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu i/o port control registers each port has its own control register, known as pac, pbc, pcc, pdc, pec, pfc which controls the input/output configuration. with this control register, each i/o pin with or without pull-high resistors can be reconfgured dynamically under software control. for the i/o pin to function as an input, the corresponding bit of the control register must be written as a 1. this will then allow the logic state of the input pin to be directly read by instructions. when the corresponding bit of the control register is written as a 0, the i/o pin will be setup as a cmos output. if the pin is currently setup as an output, instructions can still be used to read the output register . however, it should be noted that the program will in fact only read the status of the output data latch and not the actual logic status of the output pin. pin-shared functions the fexibility of the microcontroller range is greatly enhanced by the use of pins that have more than one function. limited numbers of pins can force serious design constraints on designers but by supplying pins with multi-functions, many of these diffculties can be overcome. for some pins, the chosen function of the multi-function i/o pins is set by confguration options while for others the function is set by application program control. external interrupt input the external interrupt pins, intn, are pin-shared with i/o pins. to use the pin as an external interrupt input the correct bits in the mfic register must be programmed. the pin must also be setup as an input by setting the input/output port control regi ster bit in the port control register. a pull-high resistor can also be selected via the appropriate port pull-high resistor register. note that even if the pin is setup as an external interrupt input the i/o function still remains. external timer/event counter input the timer/event counter pins, tc0 and tc1 are pin-shared with i/o pins. for these shared pins to be used as timer/event counter inputs, the timer/event counter must be confgured to be in the event counter or pulse width capture mode. this is achieved by setting the appropriate bits in the timer/event counter control register. the pins must also be setup as inputs by setting the appropriate bit in the port control register. pull-high resistor options can also be selected using the port pull-high resistor registers. note that even if the pin is setup as an external timer input the i/o function still remains. bz output the bz function output is pin-shared with an i/o pin. the output function of this pin is chosen using the ctrl2 register. if the port control register has setup the pin as an input, then the pin will function as a normal logic input with the usual pull-high selection, even if the bz function has been selected. pfd output the pfd function output is pin-shared with an i/o pin. the output function of this pin is chosen using the ctrl0 register. note that the corresponding bit of the port control register, must setup the pin as an output to enable the pfd output. if the port control register has setup the pin as an input, then the pin will function as a normal logic input with the usual pull-high selection, even if the pfd function has been selected. pwm outputs the pwm function whose outputs are pin-shared with i/o pins. the pwm output functions are chosen using the ctrl0 register. note that the corresponding bit of the port control registers, for the output pin, must setup the pin as an output to enable the pwm output. if the pins are setup as inputs, then the pin will function as a normal logic input with the usual pull-high selections, even if the pwm registers have enabled the pwm function.
rev. 1.00 4? ????st 1?? ? 011 rev. 1.00 43 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu a/d inputs the device has 12 inputs to the a/d converter. all of these analog inputs are pin-shared with i/o pins. if these pins are to be used as a/d inputs and not as i/o pins then the corresponding pcrn bits in the a/d converter control registers, ancsr0/ancsr1, must be properly setup. there are no confguration options associated with the a/d converter. if chosen as i/o pins, then full pull-high resistor confguration options remain, however if used as a/d inputs then any pull-high resistor confguration options associated with these pins will be automatically disconnected. pin remapping confguration the pin remapping function enables the function pins tc0 and tc1 to be located on different port pins. it is important not to confuse the pin remapping function with the pin-shared function, the two functions have no interdependence. the pcfg bit in the ctrl0 register allows the two function pins tc0 and tc1 to be remapped to different port pins. after power up, this bit will be reset to zero, which will defne the default port pins to which the two functions will be mapped. changing this bit will move the functions to other port pins. examination of the pin names on the package diagrams will reveal that some pin function names are repeated, this indicates a function pin that can be remapped to other port pins. if the pin name is bracketed then this indicates its alternative location. pin names without brackets indicate its default location which is the condition after power-on. pcfg bit status pcfg bit 0 1 pin mappin? tc1/p ?1 tc0/p ?? tc0/p ?1 tc1/p ?? i/o pin structures the accompanying diagrams illustrate the internal structures of some generic i/o pin types. as the exact logical construction of the i/o pin will differ from these drawings, they are supplied as a guide only to assist with the functional understanding of the i/o pins. the wide range of pin-shared structures does not permit all types to be shown.                     
                                           
                       ???     ??     ?   ?  ?          generic input/output ports
rev. 1.00 44 ????st 1?? ? 011 rev. 1.00 45 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu                       
    
                                     
            ? ?  ? pa7 nmos input/output port programming considerations within the user program, one of the things frst to consider is port initialisation. after a reset, all of the i/o data and port control registers will be set to high. this means that all i/o pins will be defaulted to an input state, the level of which depends on the other connected circuitry and whether pull-high selections have been chosen. if the port control registers are then programmed to setup some pins as outputs, these output pins will have an initial high output value unless the associated port data registers are frst programmed. selecting which pins are inputs and which are outputs can be achieved byte-wide by loading the correct values into the appropriate port control register or by programming individual bits in the port control register using the set [m].i and clr [m].i instructions. note that when using these bit control instructions, a read-modify-write operation takes place. the microcontroller must frst read in the data on the entire port, modify it to the required new bit values and then rewrite this data back to the output ports. system clock port data read from port write to port t1 t2 t3 t4 t1 t2 t3 t4 read modify write timing port a has the additional capability of providing wake-up functions. when the device is in the sleep or idle mode, various methods are available to wake the device up. one of these is a high to low transition of any of the port a pins. single or multiple pins on port a can be setup to have this function.
rev. 1.00 44 ????st 1?? ? 011 rev. 1.00 45 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu timer/event counter the provision of timers form an important part of any microcontroller, giving the designer a means of carrying out time related functions. the device contains two count-up timer of 8-bit capacity. as the timers have three different operating modes, they can be confgured to operate as a general timer, an external event counter or as a pulse width capture device. the provision of an internal prescaler to the clock circuitry on giving added range to the timers. there are two types of registers related to the timer/event counters. the frst is the register that contains the actual value of the timer and into which an initial value can be preloaded. reading from this register it retrieves the contents of the timer/event counter. the second type of associated register is the timer control register which defnes the timer options and determines how the timer is to be used. the device can have the timer clock confgured to come from the internal clock source. in addition, the timer clock source can also be confgured to come from an external timer pin. confguring the timer/event counter input clock source the timer/event counter clock source can originate from various sources, an internal clock or an external pin. the internal clock source is used when the timer is in the timer mode or in the pulse width capture mode, this internal clock source is frstly divided by a prescaler, the division ratio of which is conditioned by the timer control register bits t0ps2~t0ps0. for timer/event counter 0, the internal clock source can be f sys , pfd0 or the lxt oscillator, the choice of which is determined by the t0s[1:0] bit in the ctrl1 register. for timer/event counter 1, the clock source can be f sys /4 or the lxt oscillator, the choice of which is determined by the t1s bit in the tmr1c register.an external clock source is used when the timer is in the event counting mode, the clock source being provided on an external timer pin tcn. depending upon the condition of the tneg bit, each high to low, or low to high transition on the external timer pin will increment the counter by one. lcd clock prescaler time base 0 time base 1 b?zzer mux lirc f sys / 4 lxt confi? . opt fs clock so?rce f s lcd driver time base 0 interr?pt period time base 1 interr?pt period b?zzer                        
                  ??    ? ?   clock structure
rev. 1.00 46 ????st 1?? ? 011 rev. 1.00 47 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu             
                 
      
 
    ? ??  ? ? ?  ? -  
    ? ?    ? 8-bit timer/event counter 0 structure                
                ?  ?  ?    ??      ?   -  ?      ? ?  ? 8-bit timer/event counter 1 structure pfd0 pfd1 pfdcs mux 0 1 pfd output timer registers C tmr0, tmr1 the timer registers are special function registers located in the special purpose data memory and is the place where the actual timer value is stored. these registers are known as tmr0 and tmr1. the value in the timer registers increases by one each time an internal clock pulse is received or an external transition occurs on the external timer pin. the timer will count from the initial value loaded by the preload register to the full count of ffh at which point the timer overfows and an internal interrupt signal is generated. then the timer value will be reset with the initial preload register value and continue counting. note that to achieve a maximum full range count of ffh, all the preload registers must frst be cleared to zero. it should be noted that after power-on, the preload registers will be in an unknown condition. note that if the timer/event counter is in an off condition and data is written to its preload register, this data will be immediately written into the actual counter. however, if the counter is enabled and counting, any new data written into the preload data register during this period will remain in the preload register and will only be written into the actual counter the next time an overfow occurs. timer control registers C tmr0c, tmr1c the fexible features of the holtek microcontroller timer/event counters enable them to operate in three different modes, the options of which are determined by the contents of their respective control register. the timer control register is known as tmrnc. it is the timer control register together with its corresponding timer registers that control the full operation of the timer/event counter. before the timer can be used, it is essential that the timer control register is fully programmed with the right data to ensure its correct operation, a process that is normally carried out during program initialisation. to choose which of the three modes the timer is to operate in, either in the timer mode, the event counting mode or the pulse width capture mode, bits 7 and 6 of the timer control register, which are known as the bit pair tnm1/tnm0, must be set to the required logic levels. the timer-on bit, which is bit 4 of the timer control register and known as tnon, provides the basic on/off
rev. 1.00 46 ????st 1?? ? 011 rev. 1.00 47 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu control of the respective timer. setting the bit high allows the counter to run. clearing the bit stops the counter. bits 0~2 of the timer control register determine the division ratio of the input clock prescaler. the prescaler bit settings have no effect if an external clock source is used. if the timer is in the event count or pulse width capture mode, the active transition edge level type is selected by the logic level of bit 3 of the timer control register which is known as tneg. the t0s1, t0s0, t1s bits select the internal clock source if used. ctrl1 register bit 7 6 5 4 3 2 1 0 name t0s1 t0s0 tb00 tb01 r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~6 t0s1, t0s0: prescaler/tmr0 clock source 00: f tp =f sys prescaler clock source is f sys tmr0 clock sourced from the output clock of the prescaler 01: f tp =lxt prescaler clock source is lxt. tmr0 clock sourced from the output clock of the prescaler 10: f tp =pfd0 prescaler clock source is pfd0. tmr0 clock sourced from f sys . 11: undefned note: if pwm0c or pwm1c is enabled, the clock source of the prescaler is selected to be either f sys or pfd0 using the t0s1 bit. bit 5~4 tb01, tb00: time base 0 period selection 00: f s /2 12 01: f s /2 13 10: f s /2 14 11: f s /2 15 bit 3~0 unimplemented, read as 0 tmr0c register bit 7 6 5 4 3 2 1 0 name t0m1 t0m0 t0on t0eg t0ps? t0ps1 t0ps0 r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 1 0 0 0 bit 7,6 t0m1, t0m0: timer 0 operation mode selection 00: no mode available 01: event counter mode 10: timer mode 11: pulse width capture mode bit 5 unimplemented, read as 0 bit 4 t0on: timer/event counter counting enable 0: disable 1: enable bit 3 t0eg: event counter active edge selection 1: count on falling edge 0: count on rising edge pulse width capture active edge selection 1: start counting on rising edge, stop on falling edge 0: start counting on falling edge, stop on rising edge
rev. 1.00 48 ????st 1?? ? 011 rev. 1.00 49 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu bit 2~0 t0ps2, t0ps1, t0ps0: timer prescaler rate selection timer internal clock 000: f tp 001: f tp /2 010: f tp /4 011: f tp /8 100: f tp /16 101: f tp /32 110: f tp /64 111: f tp /128 tmr1c register bit 7 6 5 4 3 2 1 0 name t1m1 t1m0 t1s t1on t1eg r/w r/w r/w r/w r/w r/w por 0 0 0 0 1 bit 7,6 t1m1, t1m0: timer 1 operation mode selection 00: no mode available 01: event counter mode 10: timer mode 11: pulse width capture mode bit 5 t1s : timer clock source 0: f sys /4 1: lxt oscillator bit 4 t1on: timer/event counter counting enable 0: disable 1: enable bit 3 t1eg: event counter active edge selection 1: count on falling edge 0: count on rising edge pulse width capture active edge selection 1: start counting on rising edge, stop on falling edge 0: start counting on falling edge, stop on rising edge bit 2~0 unimplemented, read as 0 timer mode in this mode, the timer/event counter can be utilised to measure fxed time intervals, providing an internal interrupt signal each time the timer/event counter overfows. to operate in this mode, the operating mode select bit pair, tnm1/tnm0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the timer mode. bit7 bit6 1 0 in this mode the internal clock is used as the timer clock. the timer input clock source is f sys, f sys /4, pfd0 or the lxt oscillator. however, this timer clock source is further divided by a prescaler, the value of which is determined by the bits t0ps2~t0ps0 in the timer control register. the timer-on bit, tnon must be set high to enable the timer to run. each time an internal clock high to low transition occurs, the timer increments by one. when the timer is full and overfows, an interrupt sigal is generated and the timer will reload the value already loaded into the preload register and continue counting. a timer overfow condition and corresponding internal interrupts are two of the wake-up sources. however, the internal interrupts can be disabled by ensuring that the tne bits of the intc0 register are reset to zero.
rev. 1.00 48 ????st 1?? ? 011 rev. 1.00 49 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu                             
           timer mode timing chart event counter mode in this mode, a number of externally changing logic events, occurring on the external timer tcn pin, can be recorded by the timer/event counter. to operate in this mode, the operating mode select bit pair, tnm1/tnm0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the timer mode. bit7 bit6 0 1 in this mode, the external timer tcn, is used as the timer/event counter clock source, however it is not divided by the internal prescaler. after the other bits in the timer control register have been setup, the enable bit tnon, which is bit 4 of the timer control register, can be set high to enable the timer/event counter to run. if the active edge select bit, tneg, which is bit 3 of the timer control register, is low, the timer/event counter will increment each time the external timer pin receives a low to high transition. if the tneg is high, the counter will increment each time the external timer pin receives a high to low transition. when it is full and overfows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the corresponding interrupt control register. it is reset to zero. as the external timer pin is shared with an i/o pin, to ensure that the pin is confgured to operate as an event counter input pin, two things have to happen. the frst is to ensure that the operating mode select bits in the timer control register place the timer/event counter in the event counting mode. the second is to ensure that the port control register confgures the pin as an input. it should be noted that in the event counting mode, even if the microcontroller is in the idle/sleep mode, the timer/event counter will continue to record externally changing logic events on the timer input tcn pin. as a result when the timer overfows it will generate a timer interrupt and corresponding wake-up source.                             
event counter mode timing chart (tneg=1) pulse width capture mode in this mode, the timer/event counter can be utilised to measure the width of external pulses applied to the external timer pin. to operate in this mode, the operating mode select bit pair, tnm1/tnm0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the pulse width capture mode. bit7 bit6 1 1 in this mode the internal clock, f sys , f sys /4, pfd0 or the lxt is used as the internal clock for the 8-bit timer/event counter. however, the clock source, f sys , for the 8-bit timer is further divided
rev. 1.00 50 ????st 1?? ? 011 rev. 1.00 51 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu by a prescaler, the value of which is determined by the prescaler rate select bits t0ps2~t0ps0, which tnon, which is bit 2~0 of the timer control register, can be set high to enabl the timer/ event counter, however it will not actually start counting until an active edge is received on the external timer pin. if the active edge select bit tneg, which is bit 3 of the timer control register, is low, once a high to low transition has been received on the external timer pin, the timer/event counter will start counting until the external timer pin returns to its original high level. at this point the enable bit will be automatically reset to zero and the timer/event counter will stop counting. if the active edge select bit is high, the timer/event counter will begin counting once a low to high transition has been received on the external timer pin and stop counting when the external timer pin returns to its original low level. as before, the enable bit will be automatically reset to zero and the timer/event counter will stop counting. it is important to note that in the pulse width capture mode, the enable bit is automatically reset to zero when the external control signal on the external timer pin returns to its original level, whereas in the other two modes the enable bit can only be reset to zero under program control. the residual value in the timer/event counter, which can now be read by the program, therefore represents the length of the pulse received on the tcn pin. as the enable bit has now been reset, any further transitions on the external timer pin will be ignored. the timer cannot begin further pulse width capture until the enable bit is set high again by the program. in this way, single shot pulse measurements can be easily made. it should be noted that in this mode the timer/event counter is controlled by logical transitions on the external timer pin and not by the logic level. when the timer/event counter is full and overfows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the corresponding interrupt control register, it is reset to zero. as the tcn pin is shared with an i/o pin, to ensure that the pin is confgured to operate as a pulse width capture pin, two things have to be implemented. the first is to ensure that the operating mode select bits in the timer control register place the timer/event counter in the pulse width capture mode, the second is to ensure that the port control register confgure the pin as an input.                
                

          ?
        

      ?   ?  ? ?    ?  ? ?  ??  - pulse width capture mode timing chart (tneg=0) prescaler bits t0ps0~t0ps2 of the tmr0c register can be used to defne a division ratio for the internal clock source of the timer/event counter enabling longer time-out periods to be setup.
rev. 1.00 50 ????st 1?? ? 011 rev. 1.00 51 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu pfd function the programmable frequency divider provides a means of producing a variable frequency output suitable for applications, such as piezo-buzzer driving or other interfaces requiring a precise frequency generator. the timer/event counter overflow signal is the clock source for the pfd function, which is controlled by pfdcs bit in ctrl0. for this device the clock source can come from either timer/event counter 0 or timer/event counter 1. the output frequency is controlled by loading the required values into the timer prescaler and timer registers to give the required division ratio. the counter will begin to count-up from this preload register value until full, at which point an overfow signal is generated, causing both the pfd outputs to change state. then the counter will be automatically reloaded with the preload register value and continue counting-up. if the ctrl0 register has selected the pfd function, then for pfd output to operate, it is essential for the port b control register pbc to setup the pfd pins as outputs. pb2 must be set high to activate the pfd. the output data bits can be used as the on/off control bit for the pfd outputs. note that the pfd outputs will all be low if the output data bit is cleared to zero. using this method of frequency generation, and if a crystal oscillator is used for the system clock, very precise values of frequency can be generated.               
  


  pfd function i/o interfacing the timer/event counter, when configured to run in the event counter or pulse width capture mode, requires the use of an external timer pin for its operation. as this pin is a shared pin it must be confgured correctly to ensure that it is setup for use as a timer/event counter input pin. this is achieved by ensuring that the mode selects bits in the timer/event counter control register, either the event counter or pulse width capture mode. additionally the corresponding port control register bit must be set high to ensure that the pin is setup as an input. any pull-high resistor connected to this pin will remain valid even if the pin is used as a timer/event counter input. programming considerations when configured to run in the timer mode, the internal system clock is used as the timer clock source and is therefore synchronised with the overall operation of the microcontroller. in this mode when the appropriate timer register is full, the microcontroller will generate an internal interrupt signal directing the program flow to the respective internal interrupt vector. for the pulse width capture mode, the internal system clock is also used as the timer clock source but the timer will only run when the correct logic condition appears on the external timer input pin. as this is an external event and not synchronised with the internal timer clock, the microcontroller will only see this external event when the next timer clock pulse arrives. as a result, there may be small differences in measured values requiring programmers to take this into account during programming. the same applies if the timer is confgured to be in the event counting mode, which again is an external event and not synchronised with the internal system or timer clock. when the timer/event counter is read, or if data is written to the preload register, the clock is inhibited to avoiderrors, however as this may
rev. 1.00 5? ????st 1?? ? 011 rev. 1.00 53 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu result in a counting error, this should be taken into account by the programmer. care must be taken to ensure that the timers are properly initialised before using them for the frst time. the associated timer enable bits in the interrupt control register must be properly set otherwise the internal interrupt associated with the timer will remain inactive. the edge select, timer mode and clock source control bits in timer control register must also be correctly set to ensure the timer is properly confgured for the required application. it is also important to ensure that an initial value is frst loaded into the timer registers before the timer is switched on; this is because after power-on the initial values of the timer registers are unknown. after the timer has been initialized the timer can be turned on and off by controlling the enable bit in the timer control register. when the timer/event counter overfows, its corresponding interrupt request fag in the interrupt control register will be set. if the timer/event counter interrupt is enabled this will in turn generate an interrupt signal. however irrespective of whether the interrupts are enabled or not, a timer/event counter overfow will also generate a wake-up signal if the device is in a power-down condition. this situation may occur if the timer/event counter is in the event counting mode and if the external signal continues to change state. in such a case, the timer/event counter will continue to count these external events and if an overfow occurs the device will be woken up from its power-down condition. to prevent such a wake-up from occurring, the timer interrupt request fag should frst be set high before issuing the halt instruction to enter the idle/sleep mode . timer program example the program shows how the timer/event counter registers are setup along with how the interrupts are enabled and managed. note how the timer/event counter is turned on, by setting bit 4 of the timer control register. the timer/event counter can be turned off in a similar way by clearing the same bit. this example program sets the timer/event counters to be in the timer mode, which uses the internal system clock as their clock source. pfd programming example org 04h ; external interrupt vector org 08h ; timer counter 0 interrupt vector jmp tmr0int ; jump here when timer 0 overfows : : org 20h ; main program : : ;internal timer 0 interrupt routine tmr0int: : ;timer 0 main program placed here : : begin: ;setup timer 0 registers mov a,09bh ; setup timer 0 preload value mov tmr0,a mov a,081h ; setup timer 0 control register mov tmr0c,a ; timer mode and prescaler set to /2 ;setup interrupt register mov a,00dh ; enable master interrupt and both timer interrupts mov intc0,a : : set tmr0c.4 ; start timer 0 : :
rev. 1.00 5? ????st 1?? ? 011 rev. 1.00 53 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu pulse width modulator the device includes a multiple output 8-bit pwm function. useful for such applications such as motor speed control, the pwm function provides outputs with a fxed frequency but with a duty cycle that can be varied by setting particular values into the corresponding pwm register .            
               
                      pwm block diagram pwm operation a single register, known as pwmn and located in the data memory is assigned to each pulse width modulator channel. it is here that the 8-bit value, which represents the overall duty cycle of one modulation cycle of the output waveform, should be place d. to increase the pwm modulation frequency, each modulation cycle is subdivided into two or four individual modulation subsections, known as the 7+1 mode or 6+2 mode respectively. the required mode and the on/off control for each pwm channel is selected u sing the ctrl0 register. note that when using the pwm, it is only necessary to write the required value into the pwmn register and select the required mode setup and on/off control using the ctrl0 register, the subdivision of the wave form into its sub-modulation cycles is implemented automatically within the microcontroller hardware. the pwm clock source is the system clock f sys . this method of dividing the original modulation cycle into a further 2 or 4 sub-cycles enable the generatio n of higher pwm frequencies which allow a wider range of applications to be served. the difference between what is known as the pwm cycle frequency and the pwm modulation frequency should be understood. as the pwm clock is the system clock, f sys , and as th e pwm value is 8-bits wide, the overall pwm cycle frequency is f sys /256. however, when in the 7+1 mode of operation the pwm modulation frequency will be f sys /128, while the pwm modulation frequency for the 6+2 mode of operation will be f sys /64. pwm modulation pwm cycle frequency pwm cycle duty f sys /64 for (6+?) bits mode f sys /1?8 for (7+1) bits mode f sys /?56 [pwm]/?56
rev. 1.00 54 ????st 1?? ? 011 rev. 1.00 55 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu 6+2 pwm mode each full pwm cycle, as it is controlled by an 8-bit pwm register, has 256 clock periods. however, in the 6+2 pwm mode, each pwm cycle is subdivided into four individual sub-cycles known as modulation cycle 0~modulation cycle 3, denoted as i in the table. each one of these four sub-cycles contains 64 clock cycles. in this mode, a modulation frequency increase of four is achieved. the 8-bit pwm register value, which represents the overall duty cycle of the pwm waveform, is divided into two groups. the frst group which consists of bit 2~bit 7 is denoted here as the dc value. the second group which consists of bit 0~bit 1 is known as the ac value. in the 6+2 pwm mode, the duty cycle value of each of the four modulation sub-cycles is shown in the following table. parameter ac (0~3) dc dc(duty cycle) mod?lation cycle i (i=0~3) i?c dc/64 6+2 mode modulation cycle values the following diagram illustrates the waveforms associated with the 6+2 mode of pwm operation. it is important to note how the single pwm cycle is subdivided into 4 individual modulation cycles, numbered from 0~3 and how the ac value is related to the pwm value.                                      
    






 
 
 
 
 
 
 




 
 


 






                 ?   
                                       6+2 pwm mode                        pwm register for 6+2 mode 7+1 pwm mode each full pwm cycle, as it is controlled by an 8-bit pwm register, has 256 clock periods. however, in the 7+1 pwm mode, each pwm cycle is subdivided into two individual sub-cycles known as modulation cycle 0~modulation cycle 1, denoted as i in the table. each one of these two sub-cycles contains 128 clock cycles. in this mode, a modulation frequency increase of two is achieved. the 8-bit pwm register value, which represents the overall duty cycle of the pwm waveform, is divided into two groups. the frst group which consists of bit 1~bit 7 is denoted here as the dc value. the second group which consists of bit 0 is known as the ac value. in the 7+1 pwm mode, the duty cycle value of each of the two modulation sub-cycles is shown in the following table.
rev. 1.00 54 ????st 1?? ? 011 rev. 1.00 55 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu parameter ac(0~1) dc (duty cycle) mod?lation cycle i (i=0~1) i=?c dc/1?8 the following diagram illustrates the waveforms associated with the 7+1 mode pwm operation. it is important to note how the single pwm cycle is subdivided into 2 individual modulation cycles, numbered 0 and 1 and how the ac value is related to the pwm value.                                    
                                              
         ?     
     
    7+1 pwm mode                        pwm register for 7+1 mode pwm output control the pwm outputs are pin-shared with the i/o pins pa0 and pb0. to operate as a pwm output and not as an i/o pin, the correct bits must be set in the ctrl0 register. a zero value must also be written to the corresponding bit in the i/o port control register pac.0 and pbc.0 to ensure that the corresponding pwm output pin is setup as an output. after these two initial steps have been carried out, and of course after the required pwm value has been written into the pwmn register, writing a high value to the corresponding bit in the output data register pa.0 and pb.0 will enable the pwm data to appear on the pin. writing a zero value will disable the pwm output function and force the output low. in this way, the port data output registers can be used as an on/off control for the pwm function. note that if the ctrl0 register has selected the pwm function, but a high value has been written to its corresponding bit in the pac or pbc control register to confgure the pin as an input, then the pin can still function as a normal input line, with pull-high resistor options. pwm programming example mov a,64h ; setup pwm value of decimal 100 mov pwm0,a set ctrl0.5 ; select the 7+1 pwm mode set ctrl0.3 ; select pin pa0 to have a pwm function clr pac.0 ; setup pin pa0 as an output set pa.0 ; enable the pwm output : : clr pa.0 ; disable the pwm output_ pin pa0 forced low
rev. 1.00 56 ????st 1?? ? 011 rev. 1.00 57 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu analog to digital converter the need to interface to real world analog signals is a common requirement for many electronic systems. however, to properly process these signals by a microcontroller, they must first be converted into digital signals by a/d converters. by integrating the a/d conversion electronic circuitry into the microcontroller, the need for external components is reduced signifcantly with the corresponding follow-on benefts of lower costs and reduced component space requirements. a/d overview the device contains a 12-channel analog to digital converter which can directly interface to external analog signals, such as that from sensors or other control signals and convert these signals directly into either a 12-bit digital value. a / d c o n v e r t e r p b3 / a n 0~pb0/an3 a / d r e f e r e n c e v o l t a g e a d r l a d r h a / d d a t a r e g i s t e r s s t a r t e o c b a d o nb v ss p b5/v r e f a d c s2 ~ a d c s0 f sys pcr11~ pcr0 a c s 3~acs0 a / d c l o c k v d d a d o nb b i t v r e f s b i t 2 n (n = 0 ~ 5) p e6/ a n 4~pe3/an7 p f1/ a n 8~pf0/an9 p a 6/an10 p a 5/an11 a/d converter structure a/d converter data registers C adrl, adrh the device, which has an internal 12-bit a/d converter, requires two data registers, a high byte register, known as adrh, and a low byte register, known as adrl. after the conversion process takes place, these registers can be directly read by the microcontroller to obtain the digitised conversion value. only the high byte register, adrh, utilises its full 8-bit contents. the low byte register utilises only 4 bit of its 8-bit contents as it contains only the lowest bits of the 12-bit converted value. register bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ?drl d3 d? d1 d0 ?drh d11 d10 d9 d8 d7 d6 d5 d4 adrh, adrl register bit adrh adrl 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 name d11 d10 d9 d8 d7 d6 d5 d4 d3 d? d1 d0 r/w r r r r r r r r r r r r por x x x x x x x x x x x x x ?nknown "": unimplemented, read as 0 d11~d0: adc conversion data
rev. 1.00 56 ????st 1?? ? 011 rev. 1.00 57 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu a/d converter control registers C adcr, acsr, ancsr0, ancsr1 to control the function and operation of the a/d converter, four control registers known as ancsr0, ancsr1, adcr and acsr are provided. these 8-bit registers define functions such as the selection of which analog channel is connected to the internal a/d converter, which pins are used as analog inputs and which are used as normal i/os, the a/d clock source as well as controlling the start function and monitoring the a/d converter end of conversion status. the acs3~acs0 bits in the adcr register defne the channel number. as the device contains only one actual analog to digital converter circuit, each of the individual 12 analog inputs must be routed to the converter. it is the function of the acs3~acs0 bits in the adcr register to determine which analog channel is actually connected to the internal a/d converter. the ancsr0/ancsr1 control register also contains the pcr11~pcr0 bits which determine whether the a/d function pins are connected to external pin. if the 12-bit address on pcr11~pcr0 has a value of fffh, then all pins will all be set as analog inputs. note that if the pcr11~pcr0 bits are all set to zero, then all the pins will be setup as normal i/os. ancsr0 register bit 7 6 5 4 3 2 1 0 name pcr7 pcr6 pcr5 pcr4 pcr3 pcr? pcr1 pcr0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7~0 pcr[7:0]: defne i/o lines or analog inputs confguration to port 0: digital i/o. pin is assigned as an i/o line or pin-shared function 1: analog input. pin is switched to analog input ancsr1 register bit 7 6 5 4 3 2 1 0 name pcr11 pcr10 pcr9 pcr8 r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~4 unused, read as 0 bit 3~0 pcr[11:8]: defne i/o lines or analog inputs confguration to port 0: digital i/o. pin is assigned as a i/o line or pin-shared function 1: analog input. pin is switched to analog input adcr register bit 7 6 5 4 3 2 1 0 name st ? rt eocb ?cs3 ?cs? ?cs1 ?cs0 r/w r/w r r/w r/w r/w r/w por 0 1 0 0 0 0 bit 7 start: start the a/d conversion 010: start 01: reset the a/d converter and set eocb to 1 this bit is used to initiate an a/d conversion process. the bit is normally low but if set high and then cleared low again, the a/d converter will initiate a conversion process. when the bit is set high the a/d converter will be reset. bit 6 eocb: end of a/d conversion fag 0: a/d conversion ended 1: a/d conversion in progress this read only fag is used to indicate when an a/d conversion process has completed. when the conversion process is running the bit will be high.
rev. 1.00 58 ????st 1?? ? 011 rev. 1.00 59 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu bit 5~4 unimplemented, read as 0 bit 3~0 acs3~acs0: select a/d channel 0000: an0 0001: an1 0010: an2 0011: an3 0100: an4 0101: an5 0110: an6 0111: an7 1000: an8 1001: an9 1010: an10 1011: an11 1100: an8 1101: an9 1110: an10 1111: an11 these are the a/d channel select control bits. as there is only one internal hardware a/d converter each of the eight a/d inputs must be routed to the internal converter using these bits. acsr control register bit 7 6 5 4 3 2 1 0 name test ?donb vrefs ?dcs? ?dcs1 ?dcs0 r/w r/w r/w r/w r/w r/w r/w por 1 1 0 0 0 0 bit 7 test: for test mode use only bit 6 adonb: adc module on/off control bit 0: adc module is on 1: adc module is off bit 5 unimplemented, read as 0 bit 4 vrefs: selecte adc reference voltage 0: internal adc power 1: avref pin bit 3 unimplemented, read as 0 bit 2~0 adcs2~adcs0: select adc clock source 000: f sys /2 001: f sys /8 010: f sys /32 011: undefned 100: f sys 101: f sys /4 110: f sys /16 111: undefned these three bits are used to select the clock source for the a/d converter.
rev. 1.00 58 ????st 1?? ? 011 rev. 1.00 59 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu a/d operation the start bit in the register is used to start and reset the a/d converter. when the microcontroller sets this bit from low to high and then low again, an analog to digital conversion cycle will be initiated. when the start bit is brought from low to high but not low again, the eocb bit in the adcr register will be set to 1 and the analog to digital converter will be reset. it is the start bit that is used to control the overall start operation of the internal analog to digital converter . the eocb bit in the adcr register is used to indicate when the analog to digital conversion process is complete. this bit will be automatically set to 0 by the microcontroller after a conversion cycle has ended. in addition, the corresponding a/d interrupt request flag will be set in the interrupt control register, and if the interrupts are enabled, an appropriate internal interrupt signal will be generated. this a/d internal interrupt signal will direct the program flow to the associated a/d internal interrupt address for processing. if the a/d internal interrupt is disabled, the microcontroller can be used to poll the eocb bit in the adcr register to check whether it has been cleared as an alternative method of detecting the end of an a/d conversion cycle. the clock source for the a/d converter, which originates from the system clock f sys , is frst divided by a division ratio, the value of which is determined by the adcs2, adcs1 and adcs0 bits in the acsr register. controlling the power on/off function of the a/d converter circuitry is implemented using the value of the adonb bit. although the a/d clock source is determined by the system clock f sys , and by bits adcs2, adcs1 and adcs0, there are some limitations on the maximum a/d clock source speed that can be selected. as the minimum value of permissible a/d clock period, t ad , is 0.5s, care must be taken for system clock speeds in excess of 4mhz. for system clock speeds in excess of 4mhz, the adcs2, adcs1 and adcs0 bits should not be set to 000. doing so will give a/d clock periods that are less than the minimum a/d clock period which may result in inaccurate a/d conversion values. refer to the following table for examples, where values marked with an asterisk * show where, depending upon the device, special care must be taken, as the values may be less than the specifed minimum a/d clock period. f sys a/d clock period(t ad ) adc s 2, adc s 1, adc s 0 =000 ((f sys /2) adc s 2, adc s 1, adc s 0 =001 (f sys /8) adc s 2, adc s 1, adc s 0 =010 (f sys /32) adc s 2, adc s 1, adc s 0 =100 (f sys ) adc s 2, adc s 1, adc s 0 =101 (f sys /4) adc s 2, adc s 1, adc s 0 =110 (f sys /16) adc s 2, adc s 1, adc s 0 =011,111 1mhz 2s 8s 32s 1s 4s 16s undefned ?mhz 1s 4s 16s 500ns 2s 8s undefned 4mhz 500ns 2s 8s ?50ns* 1s 4s undefned 8mhz ?50ns* 1s 4s 1?5ns* 500ns 2s undefned 1?mhz 167ns* 667ns 2.67s 83ns* 333ns* 1s undefned a/d clock period examples
rev. 1.00 60 ????st 1?? ? 011 rev. 1.00 61 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu a/d input pins all of the a/d analog input pins are pin-shared with the i/o pins on port a, b, e, f. bits pcr7~pcr0 in the ancsr0 register and pcr11~pcr8 in the ancsr1 register, determine whether the input pins are setup as normal input/output pins or whether they are setup as analog inputs. in this way, pins can be changed under program control to change their function from normal i/o operation to analog inputs and vice versa. pull-high resistors, which are setup through register programming, apply to the input pins only when they are used as normal i/o pins, if setup as a/d inputs the pull-high resistors will be automatically disconnected. note that it is not necessary to frst setup the a/d pin as an input in the i/o port control registers to enable the a/d input as when the pcrn bits enable an a/d input, the status of the port control register will be overridden. summary of a/d conversion steps the following summarises the individual steps that should be executed in order to implement an a/d conversion process. step 1 select the required a/d conversion clock by correctly programming bits adcs2~adcs0 in the acsr register. step 2 select which pins are to be used as a/d inputs and confgure them as a/d input pins by correctly programming the pcr11~pcr0 bits in the ancsr0 and ancsr1 register. step 3 enable the a/d by clearing the adonb in the acsr register to zero. step 4 select which channel is to be connected to the internal a/d converter by correctly programming the acs3~acs0 bits which are also contained in the register. step 5 if the interrupts are to be used, the interrupt control registers must be correctly configured to ensure the a/d converter interrupt function is active. the master interrupt control bit, emi, the intc0 interrupt control register must be set to 1, the a/d converter interrupt bit, ade, must also be set to 1. step 6 the analog to digital conversion process can now be initialised by setting the start bit in the adcr register from low to high and then low again. note that this bit should have been originally cleared to zero. step 7 to check when the analog to digital conversion process is complete, the eocb bit in the adcr register can be polled. the conversion process is complete when this bit goes low. when this occurs the a/d data registers adrl and adrh can be read to obtain the conversion value. as an alternative method, if the interrupts are enabled and the stack is not full, the program can wait for an a/d interrupt to occur. note: when checking for the end of the conversion process, if the method of polling the eocb bit in the adcr register is used, the interrupt enable step above can be omitted. the accompanying diagram shows graphically the various stages involved in an analog to digital conversion process and its associated timing.
rev. 1.00 60 ????st 1?? ? 011 rev. 1.00 61 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu               
            
                                  ? ?                                                
              ? ?                                ? ?        ?                ?  ?     ?    ??  - ? ?  ?      ?    ??   ??  
          a/d conversion timing note: a/d clock must be f sys /2, f sys /8 or f sys /32 t adcs =4t ad t adc =16t ad a/d conversion timing after an a/d conversion process has been initiated by the application program, the microcontroller internal hardware will begin to carry out the conversion, during which time the program can continue with other functions. the time taken for the a/d conversion is 16t ad where t ad is equal to the a/d clock period. programming considerations when programming, the special attention must be given to the pcr[11:0] bits in the register. if these bits are all cleared to zero, no external pins will be selected for use as a/d input pins allowing the pins to be used as normal i/o pins. when this happens, the internal a/d circuitry will be power down. setting the adonb bit high has the ability to power down the internal a/d circuitry, which may be an important consideration in power sensitive applications. a/d transfer function as the device contains a 12-bit a/d converter, its full-scale converted digitised value is equal to fffh. since the full-scale analog input value is equal to the v dd voltage, this gives a single bit analog input value of v dd divided by 4096. the diagram shows the ideal transfer function between the analog input value and the digitised output alue for the a/d converter. note that to reduce the quantisation error, a 0.5lsb offset is added to the a/d converter input. except for the digitised zero value, the subsequent digitised values will change at a point 0.5lsb below where they would change without the offset, and the last full scale digitized value will change at a point 1.5lsb below the v dd level.
rev. 1.00 6? ????st 1?? ? 011 rev. 1.00 63 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu                 
          
                    ? ?  ? ? ? ?    ?? ideal a/d transfer function a/d programming example the following two programming examples illustrate how to setup and implement an a/d conversion. in the frst example, the method of polling the eocb bit in the adcr register is used to detect when the conversion cycle is complete, whereas in the second example, the a/d interrupt is used to determine when the conversion is complete. example: using an eocb polling method to detect the end of conversion clr ade ; disable adc interrupt mov a,00000001b mov acsr,a ; select f sys /8 as a/d clock and adonb=0 mov a,00000000b ; setup ancsr1/ancsr0 register to confgure port ; as a/d inputs mov ancsr1,a mov a,00000001b mov ancsr0,a ; and select an0 to be connected to the a/d ; converter : : start_conversion: clr start set start ; reset a/d clr start ; start a/d polling_eoc: sz eocb ; poll the adcr register eocb bit to detect end ; of a/d conversion jmp polling_eoc ; continue polling mov a,adrl ; read low byte conversion result value mov adrl_buffer,a ; save result to user defned register mov a,adrh ; read high byte conversion result value mov adrh_buffer,a ; save result to user defned register : jmp start_conversion ; start next a/d conversion
rev. 1.00 6? ????st 1?? ? 011 rev. 1.00 63 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu example: using the interrupt method to detect the end of conversion clr ade ; disable adc interrupt mov a,00000001b mov acsr,a ; select f sys /8 as a/d clock and adonb=0 mov a,00000000b ; setup ancsr1/ancsr0 register to confgure port ; as a/d inputs mov ancsr1,a mov a,00000001b mov ancsr0,a ; and select an0 to be connected to the a/d ; converter : : start_conversion: clr start set start ; reset a/d clr start ; start a/d clr adf ; clear adc interrupt request fag set ade ; enable adc interrupt set emi ; enable global interrupt : : : ; adc interrupt service routine adc_: mov acc_stack,a ; save acc to user defned memory mov a,status mov status_stack,a ; save status to user defned memory : : mov a,adrl ; read low byte conversion result value mov adrl_buffer,a ; save result to user defned register mov a,adrh ; read high byte conversion result value mov adrh_buffer,a ; save result to user defned register : : exit_isr: mov a,status_stack mov status,a ; restore status from user defned memory mov a, acc_stack ; restore acc from user defned memory clr adf ; clear adc interrupt fag reti note: to power off adc module, it is necessary to set adonb as 1.
rev. 1.00 64 ????st 1?? ? 011 rev. 1.00 65 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu buzzer operating in a similar way to the programmable frequency divider, the buzzer function provides a means of producing a variable frequency output, suitable for applications such as piezo-buzzer driving or other external circuits that require a precise frequency generator. the buzzer output pin buz, is pin-shared with the i/o pin, pb1. the buzzer is driven by the internal clock source, which then passes through a divider, the division ratio of which is selected by ctrl2 register to provide a range of buzzer frequencies from f s /2 2 to f s /2 9 . the clock source that generates f s , which in turn controls the buzzer frequency, can originate from three different sources, the lirc oscillator, lxt oscillator or f sys /4. the choice of which is determined by the f s clock source confguration option. ctrl2 register bit 7 6 5 4 3 2 1 0 name lcdsel? lcdsel1 lcdsel0 bzsel? bzsel1 bzsel0 buzc lxten r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 1 bit 7~5 described elsewhere bit 4~2 bzsel2~bzsel0: bz frequency select 000 : f s/2 2 001: fs/2 3 010: fs/2 4 011: fs/2 5 100: fs/2 6 101: fs/2 7 110: fs/2 8 111: f s/2 9 bit 1 buzc: i/o or buzzer function select 0: i/o 1: buz bit 0 described elsewhere if the register has selected pin pb1 to function as a buzzer output, then for correct buzzer operation it is essential that the pin must be setup as output by setting bit pbc.1 of the pbc port control register to zero. the pb1 data bit in the pb data register must also be set high to enable the buzzer outputs, if set low, the pin pb1 will remain low. in this way the single bit pb1 of the pb register can be used as an on/off control for buzzer pin output. the data setup on pin pb1 has no effect on the buzzer output.                       buzzer output pin control
rev. 1.00 64 ????st 1?? ? 011 rev. 1.00 65 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu interrupts interrupts are an important part of any microcontroller system. when an external event or an internal function such as a timer/event counter or time base require microcontroller attention, their corresponding interrupt will enforce a temporary suspension of the main program allowing the microcontroller to direct attention to their respective needs. the device contains four external interrupts and multiple internal interrupts. the external interrupts are controlled by the action of the external interrupt pins, while the internal interrupt is controlled by the timer/event counters and time base overfows. interrupt registers overall interrupt control, which means interrupt enabling and request fag setting, is controlled by using three registers, intc0, intc1 and mfic. by controlling the appropriate enable bits in these registers each individual interrupt can be enabled or disabled. also when an interrupt occurs, the corresponding request fag will be set by the microcontroller. the global enable fag cleared to zero will disable all interrupts. integ register bit 7 6 5 4 3 2 1 0 name int3s1 int3s0 int?s1 int?s0 int1s1 int1s0 int0s1 int0s0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por 1 0 1 0 1 0 1 0 bit 7~6 int3s1, int3s0: interrupt edge control for int3 pin 00: disable 01: rising edge 10: falling edge 11: both rising and falling edge bit 5~4 int2s1, int2s0: interrupt edge control for int2 pin 00: disable 01: rising edge 10: falling edge 11: both rising and falling edge bit 3~2 int1s1, int1s0: interrupt edge control for int1 pin 00: disable 01: rising edge 10: falling edge 11: both rising and falling edge bit 1~0 int0s1, int0s0: interrupt edge control for int0 pin 00: disable 01: rising edge 10: falling edge 11: both rising and falling edge
rev. 1.00 66 ????st 1?? ? 011 rev. 1.00 67 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu intc0 register bit 7 6 5 4 3 2 1 0 name t1f t0f mff t1e t0e mfe emi r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 bit 7 unimplemented, read as "0" bit 6 t1f : timer/event counter 1 interrupt request fag 0: inactive 1: active bit 5 t0f: timer/event counter 0 interrupt request fag 0: inactive 1: active bit 4 mff: multi-function interrupt request fag 0: inactive 1: active bit 3 t1e: timer/event counter 1 interrupt enable 0: disable 1: enable bit 2 t0e: timer/event counter 0 interrupt enable 0: disable 1: enable bit 1 mfe: multi-function interrupt control 0: disable 1: enable bit 0 emi: global interrupt control 0: disable 1: enable intc1 register bit 7 6 5 4 3 2 1 0 name tb1f tb0f ?df tb1e tb0e ?de r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 bit 7 unimplemented, read as "0" bit 6 tb1f : time base 1 interrupt request fag 0: inactive 1: active bit 5 tb0f: time base 0 interrupt request fag 0: inactive 1: active bit 4 adf: a/d conversion interrupt request fag 0: inactive 1: active bit 3 unimplemented, read as 0 bit 2 tb1e: time base 1 interrupt enable 0: disable 1: enable bit 1 tb0e: time base 0 interrupt enable 0: disable 1: enable
rev. 1.00 66 ????st 1?? ? 011 rev. 1.00 67 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu bit 0 ade: a/d conversion interrupt enable 0: disable 1: enable mfic register bit 7 6 5 4 3 2 1 0 name int3f int ? f int 1 f int 0 f int3 e int ?e int 1e int 0e r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 0 bit 7 int3f: int3 interrupt request fag 0: inactive 1: active bit 6 int2f : int2 interrupt request fag 0: inactive 1: active bit 5 int1f: int1 interrupt request fag 0: inactive 1: active bit 4 int0f: int0 interrupt request fag 0: inactive 1: active bit 3 int3e : int3 interrupt enable 0: disable 1: enable bit 2 int2e: int2 interrupt enable 0: disable 1: enable bit 1 int1e : int1 interrupt enable 0: disable 1: enable bit 0 int0e: int0 interrupt enable 0: disable 1: enable interrupt operation a timer/event counter overfow, a time base event or an active edge on the external interrupt pin will all generate an interrupt request by setting their corresponding request fag, if their appropriate interrupt enable bit is set. when this happens, the program counter, which stores the address of the next instruction to be executed, will be transferred onto the stack. the program counter will then be loaded with a new address which will be the value of the corresponding interrupt vector. the microcontroller will then fetch its next instruction from this interrupt vector. the instruction at this vector will usually be a jmp statement which will jump to another section of program which is known as the interrupt service routine. here is located the code to control the appropriate interrupt. the interrupt service routine must be terminated with a reti instruction, which retrieves the original program counter address from the stack and allows the microcontroller to continue with normal execution at the point where the interrupt occurred. the various interrupt enable bits, together with their associated request fags, are shown in the following diagram with their order of priority.
rev. 1.00 68 ????st 1?? ? 011 rev. 1.00 69 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu m?lti-f?nction timer 0 mff t0f mfe t0e emi 04h emi 08h timer 1 t1f t1e emi 0ch 10h ?/d ?df ?de emi 14h time base 0 tb0f tb0e emi 18h time base 1 tb1f tb1e emi interr?pt name req?est fla?s enable bits master enable vector emi a?to disabled in isr low int1 int1f int1e int? int?f int?e int0 int0f int0e interr?pts contained within m?lti-f?nction interr?pts int3 int3f int3e priority hi?h xxe enable bits xxf req?est fla?? a?to reset in isr legend xxf req?est fla?? no a?to reset in isr interrupt structure once an interrupt subroutine is serviced, all the other interrupts will be blocked, as the emi bit will be cleared automatically. this will prevent any further interrupt nesting from occurring. however, if other interrupt requests occur during this interval, although the interrupt will not be immediately serviced, the request fag will still be recorded. if an interrupt requires immediate servicing while the program is already in another interrupt service routine, the emi bit should be set after entering the routine, to allow interrupt nesting. if the stack is full, the interrupt request will not be acknowledged, even if the related interrupt is enabled, until the stack pointer is decremented. if immediate service is desired, the stack must be prevented from becoming full. when an interrupt request is generated it takes 2 or 3 instruction cycles before the program jumps to the interrupt vector. if the device is in the sleep or idle mode and is woken up by an interrupt request then it will take 3 cycles before the program jumps to the interrupt vector . wait for ? ~ 3 instr?ction cycles main pro?ram isr entry enable bit set ? main pro?ram reti ( it will set emi a?tomatically ) ??tomatically disable interr?pt clear emi & req?est fla? interr?pt req?est or interr?pt fla? set by instr?ction n y interrupt flow
rev. 1.00 68 ????st 1?? ? 011 rev. 1.00 69 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu interrupt priority interrupts, occurring in the interval between the rising edges of two consecutive t2 pulses, will be serviced on the latter of the two t2 pulses, if the corresponding interrupts are enabled. in case of simultaneous requests, the following table shows the priority that is applied. these can be masked by resetting the emi bit. interrupt source priority vector m?lti - f?nction interr?pt(external interr?pt 0~3) 1 04h timer/event counter 0 overfow ? 08h timer/event counter 1 overfow 3 0ch ?dc interr?pt 4 10h time base 0 interr?pt 5 14h time base 1 interr?pt 6 18h in cases where both external and internal interrupts are enabled and where an external and internal interrupt occurs simultaneously, the external interrupt will always have priority and will therefore be serviced frst. suitable masking of the individual interrupts using the interrupt registers can prevent simultaneous occurrences. multi-function interrupt the device contains a multi-function interrupt. unlike the othe r independent interrupts, this interrupt has no independent source, but rather is formed from external interrupt source. a multi-function interrupt request will take place when the multi-function interrupt request flag, mff is set. the multi-function interrupt fag will be set when any of their included functions generate an interrupt request flag. to allow the program to branch to its respective interrupt vector address, when the multi-function interrupt is enabled and the stack is not full, and either one of the interrupts contained within the multi-function interrupt occurs, a subroutine call to the multi-function interrupt vector will take place. when the interrupt is serviced, the related multi-function request flag will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. the type of transition that will trigger the external interrupts, whether high to low, low to high or both is determined by the intns0 and intns1 bits, in the integ register. these bits can also disable the external interrupt function. intns1 intns0 edge trigger type 0 0 external interr?pt disable 0 1 risin? ed? e tri??er 1 0 fallin? ed? e tri??er 1 1 both ed ? e tri??er the external interrupt pins are pin-shared with the i/o pins and can only be confgured as external interrupt pins if the corresponding external interrupt enable bit in the mfic register has been set and the edge trigger type has been selected using the integ register. the pins must also be setup as an input by setting the port control registers.
rev. 1.00 70 ????st 1?? ? 011 rev. 1.00 71 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu a/d converter interrupt the a/d converter interrupt is controlled by the termination of an a/d conversion process. an a/d converter interrupt request will take place when the a/d converter interrupt request fag, adf, is set, which occurs when the a/d conversion process fnishes. to allow the program to branch to its respective interrupt vector address, the global interrupt enable bit, emi, and a/d interrupt enable bit, ade, must frst be set. when the interrupt is enabled, the stack is not full and the a/d conversion process has ended, a subroutine call to the a/d converter interrupt vector, will take place. when the interrupt is serviced, the a/d converter interrupt fag, adf, will be automatically cleared. the emi bit will also be automatically cleared to disable other interrupts. timer/event counter interrupt for a timer/event counter interrupt to occur, the global interrupt enable bit, emi, and the corresponding timer interrupt enable bit, tne, must first be set. an actual timer/event counter interrupt will take place when the timer/event counter request fag, tnf, is set, a situation that will occur when the relevant timer/event counter verfows. when the interrupt is enabled, the stack is not full and a timer/event counter overfow occurs, a subroutine call to the relevant timer interrupt vector, will take place. when the interrupt is serviced, the timer interrupt request fag, tnf, will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. time base interrupts time base interrupts functions are to provide regular time signal in the form of an internal interrupt. they are controlled by the overflow signals from their respective timer functions. when these happens their respective interrupt request fags, tb0f or tb1f will be set. to allow the program to branch to their respective interrupt vector addresses, the global interrupt enable bit, emi and time base enable bits, tb0e or tb1e, must frst be set. when the interrupt is enabled, the stack is not full and the time base overflows, a subroutine call to their respective vector locations will take place. when the interrupt is serviced, the respective interrupt request fag, tb0f or tb1f, will be automatically reset and the emi bit will be cleared to disable other interrupts. ctrl1 register bit 7 6 5 4 3 2 1 0 name t0s1 t0s0 tb01 tb00 r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~6 described elsewhere bit 5~4 tb01, tb00: time base 0 period selection 00: f s /2 12 01: f s /2 13 10: f s /2 14 11: f s /2 15 bit 3~0 unimplemented, read as 0
rev. 1.00 70 ????st 1?? ? 011 rev. 1.00 71 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu ctrl4 register bit 7 6 5 4 3 2 1 0 name lxtlp tb1? tb11 tb10 r/w r/w r/w r/w r/w por 0 1 1 1 bit 7~3 described elsewhere bit 2~0 tb12~tb10: time base 1 clock selection 000: f s /2 8 001: f s /2 9 010: f s /2 10 011: f s /2 11 100: f s /2 12 101: f s /2 13 110: f s /2 14 111: f s /2 15                           
       
                     
       ?  time base interrupts interrupt wake-up function each of the interrupt functions has the capability of waking up the microcontroller when in the sleep or idle mode. a wake-up is generated when an interrupt request fag changes from low to high and is independent of whether the interrupt is enabled or not. therefore, even though the device is in the sleep or idle mode and its system oscillator stopped, situations such as external edge transitions on the external interrupt pins, a low power supply voltage or may cause their respective interrupt fag to be set high and consequently generate an interrupt. care must therefore be taken if spurious wake-up situations are to be avoided. if an interrupt wake-up function is to be disabled then the corresponding interrupt request fag should be set high before the device enters the sleep or idle mode. the interrupt enable bits have no effect on the interrupt wake-up function. programming considerations by disabling the relevant interrupt enable bits, a requested interrupt can be prevented from being serviced, however, once an interrupt request flag is set, it will remain in this condition in the interrupt register until the corresponding interrupt is serviced or until the request fag is cleared by a software instruction. where a certain interrupt is contained within a multi-function interrupt, then when the interrupt service routine is executed, as only the multi-function interrupt request flag, mff, will be automatically cleared, the individual request flag for the function needs to be cleared by the application program. it is recommended that programs do not use the call instruction within the interrupt service subroutine. interrupts often occur in an unpredictable manner or need to be serviced immediately. if only one stack is left and the interrupt is not well controlled, the original control sequence will be damaged once a call subroutine is executed in the interrupt subroutine. every interrupt has the
rev. 1.00 7? ????st 1?? ? 011 rev. 1.00 73 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu capability of waking up the microcontroller when it is in sleep or idle mode, the wake up being generated when the interrupt request fag changes from low to high. if it is required to prevent a certain interrupt from waking up the microcontroller then its respective request fag should be frst set high before entering the sleep or idle mode. as only the program counter is pushed onto the stack, then when the interrupt is serviced, if the contents of the accumulator, status register or other registers are altered by the interrupt service program, their contents should be saved in advance. to return from an interrupt subroutine, either a ret or reti instruction may be executed. the reti instruction in addition to executing a return to the main program also automatically sets the emi bit high to allow further interrupts. the ret instruction however only executes a return to the main program leaving the emi bit in its present zero state and therefore disabling the execution of further interrupts. lcd function for large volume applications, which incorporate an lcd in their design, the use of a custom display rather than a more expensive character based display reduces costs signifcantly. however, the corresponding com and seg signals required, which vary in both amplitude and time, to drive such a custom display require many special considerations for proper lcd operation to occur. this device contains an lcd driver function, which with their internal lcd signal generating circuitry and various options, will automatically generate these time and amplitude varying signals to provide a means of direct driving and easy interfacing to a range of custom lcds. duty driver no. bias bias type wave type 1/4 ?34 1/3 or 1/4 r ? or b 1/8 198 lcd selections                              
    
     
                              
    
     
       
  r type bias voltage levels
rev. 1.00 7? ????st 1?? ? 011 rev. 1.00 73 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu display memory an area of data memory is especially reserved for use for the lcd display data. this data area is known as the display memory. any data written here will be automatically read by the internal display driver circuits, which will in turn automatically generate the necessary lcd signals. therefore any data written into this memory will be immediately refected into the actual display connected to the microcontroller. as the display memory addresses overlap those of the general purpose data memory, it stored in its own independent bank 1 area. the data memory bank to be used is chosen by using the bank pointer, which is a special function register in the data memory, with the name, bp. to access the display memory therefore requires frst that bank 1 is selected by writing a value of 01h to the bp register. after this, the memory can then be accessed by using indirect addressing through the use of memory pointer mp1. with bank 1 selected, then using mp1 to read or write to the memory area, starting with address 40h, will result in operations to the display memory. directly addressing the display memory is not applicable and will result in a data access to the bank 0 general purpose data memory. the accompanying display memory map diagrams shows how the internal display memory is mapped to the segments and commons of the display for the device.                                    lcd registers control registers in the data memory, are used to control the various setup features of the lcd driver. there are three control register for the lcd function, ctrl2, lcdc and lcdo. various bits in these registers control functions such as duty type, bias type, bias resistor selection as well as overall lcd enable and disable. the lcden bit in the lcdc register, which provide the overall lcd enable/disable function, will only be effective when the device is in the normal, slow or idle mode. if the device is in the sleep mode then the display will always be disabled. bits rsel0 and rsel1 in the lcdc register select the internal bias resistors to supply the lcd panel with the correct bias voltages. a choice to best match the lcd panel used in the application can be selected also to minimise bias current. the type bit in the same register is used to select whether type a or type b lcd control signals are used. the lcdo register is used to determine if the output function of display pins are used as segment drivers or cmos outputs or i/o pins. the bits lcdsel2~lcdsel0 in the ctrl2 register are used to select lcd clock source.
rev. 1.00 74 ????st 1?? ? 011 rev. 1.00 75 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu ctrl2 register bit 7 6 5 4 3 2 1 0 name lcdsel? lcdsel1 lcdsel0 bzsel? bzsel1 bzsel0 buzc lxten r/w r/w r/w r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 0 0 1 bit 7~5 lcdsel2~lcdsel0: lcd driver clock 000: fs/2 2 001: fs/2 3 010: fs/2 4 011: fs/2 5 100: fs/2 6 101: fs/2 7 110: fs/2 8 111: reserved bit 4~0 described elsewhere lcdc register bit 7 6 5 4 3 2 1 0 name type bi?s rsel1 rsel0 lcden r/w r/w r/w r/w r/w r/w por 0 0 0 0 0 bit 7 type: lcd type a or type b 0: type a 1: type b bit 6~4 unused bit, read as 0 bit 3 bias: defne lcd bias 0: 1/3 bias; 1/4 duty 1: 1/4 bias; 1/8 duty bit 2~1 rsel1, rsel0: select resistor for r type lcd bias current 00: 600k 01: 300k 10: 100k 11: 30k bit 0 lcden: lcd enable/disable control 0: disable 1: enable lcdo register bit 7 6 5 4 3 2 1 0 name lcdo3 lcdo? lcdo1 lcdo0 r/w r/w r/w r/w r/w por 0 0 0 0 bit 7~4 unused bit, read as 0 bit 3 lcdo3: lcd com or i/o function control bit(com0~com3) 0: i/o 1: lcd com bit 2 lcdo2: lcd seg or i/o function control bit(seg16~seg22) 0: i/o or a/d function 1: lcd seg or com
rev. 1.00 74 ????st 1?? ? 011 rev. 1.00 75 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu bit 1 lcdo1: lcd seg or i/o function control bit(seg8~seg15) 0: i/o 1: lcd seg bit 0 lcdo0: lcd seg or i/o function control bit(seg0~seg7) 0: i/o 1: lcd seg lcd clock source the lcd clock source is the internal clock signal, f s , divided using an internal divider circuit. the f s internal clock is supplied by the lxt oscillator, f sys /4 or the lirc oscillator, the choice of which is determined by a confguration option. for proper lcd operation, this arrangement is provided to generate an ideal lcd clock source frequency of 4khz. the options of lcd clock frequency are listed in the following table f s clock source lcd clock selection lirc lirc/? 3 lxt lxt/? 3 f sys /4 f sys /? 4 ~f sys /? 10 lcd driver output the nature of liquid crystal display requires that only ac voltage can be applied to its pixel as the application of dc voltage to lcd pixel may cause permanent damage. for this reason the relative contrast of an lcd display is controlled by the actual rms voltage applied to each pixel, which is equal to the rms value of the voltage on the com pin minus the voltage applied to the seg pin. this differential rms voltage must be greater than the lcd saturation voltage for the pixel to be on and less than the threshold voltage for the pixel to be off. the requirement to limit the dc voltage to zero and to control as many pixels as possible with a minimum number of connections, requires that both a time and amplitude signal is generated and applied to the application lcd. these time and amplitude varying signals are automatically generated by the lcd driver circuits in the microcontroller. what is known as the duty determines the number of common lines used, which are also known as backplanes or coms. the duty, which is chosen by a control bit to have a value of 1/4, 1/8 and which equates to a com number of 4, 8, therefore defnes the number of time divisions within each lcd signal frame. two types of signal generation are also provided, known as type a and type b, the required type is selected via the type bit in the lcdc register. type b offers lower frequency signals, however lower frequencies may introduce fickering and infuence display clarity . lcd voltage source and biasing the time and amplitude varying signals generated by the lcd driver function require the generation of several voltage levels for their operation. the number of voltage levels used by the signal depends upon the value of the bias bit in the lcdc register. the device has r type biasing only. lcd voltage source is v dd . for the r type 1/3 bias selection, fve voltage levels v ss , v a , v b , v c and v d are utilised. the voltage v a is equal to v dd , v b is equal to v dd 2/3 , while v c is equal to v dd 1/3. for the r type 1/4 bias selection, fve voltage levels v ss , v a , v b , v c and v d are utilised. the voltage v a is equal to v dd , v b is equal to v dd 3/4, v c is equal to v dd 2/4 , while v d is equal to v dd 1/4. in addition to selecting 1/3 or 1/4 bias, several values of bias resistor can be chosen using bits in the lcdc register. different values of internal bias resistors can be selected using the rsel0 and resel1 bits in the lcdc register.
rev. 1.00 76 ????st 1?? ? 011 rev. 1.00 77 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu low voltage detector C lvd the device has a low voltage detector function, also known as lvd. this enabled the device to monitor the power supply voltage, v dd , and provide a warning signal should it fall below a certain level. this function may be especially useful in battery applications where the supply voltage will gradually reduce as the battery ages, as it allows an early warning battery low signal to be generated. the low voltage detector also has the capability of generating an interrupt signal. lvd register the low voltage detector function is controlled using a single register with the name lvdc. three bits in this register, v lvd2 ~v lvd0 , are used to select one of eight fxed voltages below which a low voltage condition will be detemined. a low voltage condition is indicated when the lvdo bit is set. if the lvdo bit is low, this indicates that the v dd voltage is above the preset low voltage value. the lvden bit is used to control the overall on/off function of the low voltage detector. setting the bit high will enable the low voltage detector. clearing the bit to zero will switch off the internal low voltage detector circuits. as the low voltage detector will consume a certain amount of power, it may be desirable to switch off the circuit when not in use, an important consideration in power sensitive battery powered applications. lvdc register bit 7 6 5 4 3 2 1 0 name lvdo lvden vlvd ? vlvd1 vlvd0 r/w r r/w r/w r/w r/w por 0 0 0 0 0 bit 7~6 unimplemented, read as "0" bit 5 lvdo: lvd output flag 0: no low voltage detect 1: low voltage detect bit 4 lvden: low voltage detector control 0: disable 1: enable bit 3 unimplemented, read as 0 bit 2~0 vlvd2~vlvd0: select lvd voltage 000: 2.0v 001: 2.2v 010: 2.4v 011: 2.7v 100: 3.0v 101: 3.3v 110: 3.6v 111: 4.0v
rev. 1.00 76 ????st 1?? ? 011 rev. 1.00 77 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu lvd operation the low voltage detector function operates by comparing the power supply voltage, v dd , with a pre-specifed voltage level stored in the lvdc register. this has a range of between 2.0v and 4.0v. when the power supply voltage, v dd , falls below this pre-determined value, the lvdo bit will be set high indicating a low power supply voltage condition. the low voltage detector function is supplied by a reference voltage which will be automatically enabled. when the device is powered down the low voltage detector will remain active if the lvden bit is high. after enabling the low voltage detector, a time delay t lvds should be allowed for the circuitry to stabilise before reading the lvdo bit. note also that as the v dd voltage may rise and fall rather slowly, at the voltage nears that of v lvd, there may be multiple bit lvdo transitions. vdd v lvd lvdo lvden t lvds lvd operation confguration options confguration options refer to certain options within the mcu that are programmed into the device during the programming process. during the development process, these options are selected using the ht-ide software development tools. as these options are programmed into the device using the hardware programming tools, once they are selected they cannot be changed later using the application program. all options must be defned for proper system function, the details of which are shown in the table. no. options 1 watchdo ? timer f?nction: ?lways enable or by s/w control ? fs clock so?rce: lirc? f sys or lxt 3 hirc freq?ency selection: 4mhz? 8mhz or 1?mhz 4 6vwhprvfloodwrufrqjxudwlrq+;7+?5&(5&+?5&/;7 5 ?lways enabled or ?pplication pro?ram enabled
rev. 1.00 78 ????st 1?? ? 011 rev. 1.00 79 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu application circuits vdd vss osc1 osc? xt1 xt? osc circ?it osc circ?it see oscillator section see oscillator section pb3/?n0 pb?/pfd/?n1 p?5/?n11 pb7/com0 pb6/com1 pb5/com? pb4/com3 pc0/seg0 pe3/?n7/seg19/com7 pe4/?n6/seg?0/com6 pe5/?n5/seg?1/com5 pe6/?n4/seg??/com4 p?1/int?/tc1/[tc0] p?0/int1/pwm0 p??/int3/tc0/[tc1] p?7
rev. 1.00 78 ????st 1?? ? 011 rev. 1.00 79 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu instruction set summary the following table depicts a summary of the instruction set categorised according to function and can be consulted as a basic instruction reference using the following listed conventions. table conventions x: bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address mnemonic description cycles flag affected arithmetic ?dd ??[m] ?dd data memory to ?cc 1 z? c? ?c? ov ?ddm ??[m] ?dd ?cc to data memory 1 note z? c? ?c? ov ?dd ??x ?dd immediate data to ?cc 1 z? c? ?c? ov ?dc ??[m] ?dd data memory to ?cc with carry 1 z? c? ?c? ov ?dcm ??[m] ?dd ?cc to data memory with carry 1 note z? c? ?c? ov sub ??x s?btract immediate data from the ?cc 1 z? c? ?c? ov sub ??[m] s?btract data memory from ?cc 1 z? c? ?c? ov subm ??[m] s?btract data memory from ?cc with res?lt in data memory 1 note z? c? ?c? ov sbc ??[m] s?btract data memory from ?cc with carry 1 z? c? ?c? ov sbcm ??[m] s?btract data memory from ?cc with carry ? res?lt in data memory 1 note z? c? ?c? ov d?? [m] decimal adj?st ?cc for ?ddition with res?lt in data memory 1 note c logic operation ?nd ??[m] lo?ical ?nd data memory to ?cc 1 z or ??[m] lo?ical or data memory to ?cc 1 z xor ??[m] lo?ical xor data memory to ?cc 1 z ?ndm ??[m] lo?ical ?nd ?cc to data memory 1 note z orm ??[m] lo?ical or ?cc to data memory 1 note z xorm ??[m] lo?ical xor ?cc to data memory 1 note z ?nd ??x lo?ical ?nd immediate data to ?cc 1 z or ??x lo?ical or immediate data to ?cc 1 z xor ??x lo?ical xor immediate data to ?cc 1 z cpl [m] complement data memory 1 note z cpl? [m] complement data memory with res?lt in ?cc 1 z increment & decrement inc? [m] increment data memory with res?lt in ?cc 1 z inc [m] increment data memory 1 note z dec? [m] decrement data memory with res?lt in ?cc 1 z dec [m] decrement data memory 1 note z rotate rr? [m] rotate data memory ri?ht with res?lt in ?cc 1 none rr [m] rotate data memory ri?ht 1 note none rrc? [m] rotate data memory ri?ht thro??h carry with res?lt in ?cc 1 c rrc [m] rotate data memory ri?ht thro??h carry 1 note c rl? [m] rotate data memory left with res?lt in ?cc 1 none rl [m] rotate data memory left 1 note none rlc? [m] rotate data memory left thro??h carry with res?lt in ?cc 1 c rlc [m] rotate data memory left thro??h carry 1 note c
rev. 1.00 80 ????st 1?? ? 011 rev. 1.00 81 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu mnemonic description cycles flag affected data move mov ??[m] move data memory to ?cc 1 none mov [m]?? move ?cc to data memory 1 note none mov ??x move immediate data to ?cc 1 none bit operation clr [m].i clear bit of data memory 1 note none set [m].i set bit of data memory 1 note none branch jmp addr j?mp ?nconditionally ? none sz [m] skip if data memory is zero 1 note none sz? [m] skip if data memory is zero with data movement to ?cc 1 note none sz [m].i skip if bit i of data memory is zero 1 note none snz [m].i skip if bit i of data memory is not zero 1 note none siz [m] skip if increment data memory is zero 1 note none sdz [m] skip if decrement data memory is zero 1 note none siz? [m] skip if increment data memory is zero with res?lt in ?cc 1 note none sdz? [m] skip if decrement data memory is zero with res?lt in ?cc 1 note none c? ll addr s?bro?tine call ? none ret ret?rn from s?bro?tine ? none ret ??x ret?rn from s?bro?tine and load immediate data to ?cc ? none reti ret?rn from interr?pt ? none table read t ?brd [m] read table to tblh and data memory ? note none t ? brdl [m] read table (last pa? e) to tblh and data memory ? note none miscellaneous nop no operation 1 none clr [m] clear data memory 1 note none set [m] set data memory 1 note none clr wdt clear watchdo ? timer 1 to ? pdf clr wdt1 pre-clear watchdo ? timer 1 to ? pdf clr wdt? pre-clear watchdo ? timer 1 to ? pdf sw ? p [m] swap nibbles of data memory 1 note none sw ?p ? [m] swap nibbles of data memory with res?lt in ?cc 1 none h? lt enter power down mode 1 to ? pdf note: 1. for skip instructions, if the result of the comparison involves a skip then two cycles are required, if no skip takes place only one cycle is required. 2. any instruction which changes the contents of the pcl will also require 2 cycles for execution. 3. for the "clr wdt1" and "clr wdt2" instructions the to and pdf flags may be affected by the execution status. the to and pdf flags are cleared after both "clr wdt1" and "clr wdt2" instructions are consecutively executed. otherwise the to and pdf fags remain unchanged.
rev. 1.00 80 ????st 1?? ? 011 rev. 1.00 81 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu instruction defnition ?dd data memory to ?cc with carry the contents of the specifed data memory, accumulator and the carry fag are added. the res ?lt is stored in the ?cc?m? lator. ?cc ?cc + [m] + c ov ? z? ?c? c ?dd ?cc to data memory with carry the contents of the specifed data memory, accumulator and the carry fag are added. the result is stored in the specifed data memory. [m] ?cc + [m] + c ov ? z? ?c? c ?dd data memory to ?cc the contents of the specifed data memory and the accumulator are added. the res?lt is stored in the ?cc?m? lator. ?cc ?cc + [m] ov ? z? ?c? c ?dd immediate data to ?cc the contents of the accumulator and the specifed immediate data are added. the res?lt is stored in the ?cc?m? lator. ?c ?cc + x ov ? z? ?c? c ?dd ?cc to data memory the contents of the specifed data memory and the accumulator are added. the result is stored in the specifed data memory. [m] ?cc + [m] ov ? z? ?c? c lo?ical ?nd data memory to ?cc data in the accumulator and the specifed data memory perform a bitwise logical ? nd operation. the res?lt is stored in the ?cc?m? lator. ?cc ?cc ?nd [m] z lo?ical ?nd immediate data to ?cc data in the ?cc?m? lator and the specified immediate data perform a bitwise lo?ical ? nd operation. the res?lt is stored in the ?cc?m? lator. ?cc ?cc ?nd x z lo?ical ?nd ?cc to data memory data in the specifed data memory and the accumulator perform a bitwise logical ? nd operation. the res? lt is stored in the data memory. [m] ?cc ?nd [m] z adc a,[m] description operation affected fag(s) adcm a,[m] description operation affected fag(s) add a,[m] description operation affected fag(s) add a,x description operation affected fag(s) addm a,[m] description operation affected fag(s) and a,[m] description operation affected fag(s) and a,x description operation affected fag(s) andm a,[m] description operation affected fag(s)
rev. 1.00 8? ????st 1?? ? 011 rev. 1.00 83 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu s?bro?tine call unconditionally calls a subroutine at the specifed address. the program counter then increments by 1 to obtain the address of the next instr ? ction which is then p? shed onto the stack. the specified address is then loaded and the pro? ram contin ? es exec ? tion from this new address. ? s this instr? ction req ? ires an additional operation? it is a two cycle instr?ction. stack pro?ram co?nter + 1 pro?ram co?nter addr none clear data memory each bit of the specifed data memory is cleared to 0. [m] 00h none clear bit of data memory bit i of the specifed data memory is cleared to 0. [m].i 0 none clear watchdo ? timer the to, pdf fags and the wdt are all cleared. wdt cleared to 0 pdf 0 to ? pdf pre-clear watchdo ? timer the to, pdf fags and the wdtare all cleared. note that this instruction works in conj? nction with clr wdt? and m? st be exec? ted alternately with clr wdt? to have effect. repetitively exec ?tin? this instr? ction witho? t alternately exec?tin? clr wdt? will have no effect. wdt cleared to 0 pdf 0 to ? pdf pre-clear watchdo ? timer the to, pdf fags and the wdtare all cleared. note that this instruction works in conj? nction with clr wdt1 and m? st be exec? ted alternately with clr wdt1 to have effect. repetitively exec ?tin? this instr? ction witho? t alternately exec?tin? wdt cleared to 0 pdf 0 to ? pdf call addr description operation affected fag(s) clr [m] description operation affected fag(s) clr [m].i description operation affected fag(s) clr wdt description operation affected fag(s) clr wdt1 description operation affected fag(s) clr wdt2 description operation affected fag(s)
rev. 1.00 8? ????st 1?? ? 011 rev. 1.00 83 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu complement data memory each bit of the specified data memory is lo ? ically complemented (1 ' s complement). bits which previo ? sly contained a 1 are chan? ed to 0 and vice versa. [m] [m] z complement data memory with res?lt in ?cc each bit of the specified data memory is lo ? ically complemented (1 ' s complement). bits which previo ? sly contained a 1 are chan? ed to 0 and vice versa. the complemented res ?lt is stored in the ?cc?m?lator and the contents of the data memory remain ?nchan?ed. ?cc [m] z decimal-?dj?st ?cc for addition with res?lt in data memory convert the contents of the ?cc?m?lator val? e to a bcd ( binary coded decimal) val?e res?ltin? from the previo? s addition of two bcd variables. if the low nibble is greater than 9 or if ac fag is set, then a value of 6 will be added to the low nibble. otherwise the low nibble remains ?nchan? ed. if the hi? h nibble is ?reater than 9 or if the c fag is set, then a value of 6 will be added to the high nibble. essentially ? the decimal conversion is performed by addin? 00h? 06h? 60h or 66h depending on the accumulator and fag conditions. only the c fag may be affected by this instr ? ction which indicates that if the ori? inal bcd s?m is ?reater than 100? it allows m?ltiple precision decimal addition. [m] ?cc + 00h or [m] ?cc + 06h or [m] ?cc + 60h or [m] ?cc + 66h c decrement data memory data in the specifed data memory is decremented by 1. [m] [m] D 1 z decrement data memory with res?lt in ?cc data in the specifed data memory is decremented by 1. the result is stored in the ?cc?m? lator. the contents of the data memory remain ?nchan?ed. ?cc [m] D 1 z cpl [m] description operation affected fag(s) cpla [m] description operation affected fag(s) daa [m] description operation affected fag(s) dec [m] description operation affected fag(s) deca [m] description operation affected fag(s)
rev. 1.00 84 ????st 1?? ? 011 rev. 1.00 85 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu enter power down mode this instr?ction stops the pro?ram exec?tion and t? rns off the system clock. the contents of the data memory and re ? isters are retained. the wdt and prescaler are cleared. the power down fla ? pdf is set and the wdt time-o? t fla? to is cleared. to 0 pdf 0 to ? pdf increment data memory data in the specifed data memory is incremented by 1. [m] [m]+1 z increment data memory with res?lt in ?cc data in the specifed data memory is incremented by 1. the result is stored in the ?cc?m? lator. the contents of the data memory remain ?nchan?ed. ?cc [m]+1 z j?mp ?nconditionally the contents of the pro ? ram co? nter are replaced with the specified address. pro ? ram exec ? tion then contin ? es from this new address. ? s this req ? ires the insertion of a d ?mmy instr?ction while the new address is loaded? it is a two cycle instr?ction. pro?ram co?nter addr none move data memory to ?cc the contents of the specifed data memory are copied to the accumulator. ?cc [m] none move immediate data to ?cc the immediate data specifed is loaded into the accumulator. ?cc x none move ?cc to data memory the contents of the accumulator are copied to the specifed data memory. [m] ?cc none no operation no operation is performed. exec?tion contin?es with the next instr?ction. no operation none halt description operation affected fag(s) inc [m] description operation affected fag(s) inca [m] description operation affected fag(s) jmp addr description operation affected fag(s) mov a,[m] description operation affected fag(s) mov a,x description operation affected fag(s) mov [m],a description operation affected fag(s) nop description operation affected fag(s)
rev. 1.00 84 ????st 1?? ? 011 rev. 1.00 85 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu lo?ical or data memory to ?cc data in the accumulator and the specifed data memory perform a bitwise logical or operation. the res ?lt is stored in the ?cc?m? lator. ?cc ?cc " or " [m] z lo?ical or immediate data to ?cc data in the ?cc?m? lator and the specified immediate data perform a bitwise lo? ical or operation. the res?lt is stored in the ?cc?m? lator. ?cc ?cc " or " x z lo?ical or ?cc to data memory data in the specifed data memory and the accumulator perform a bitwise logical or operation. the res ? lt is stored in the data memory. [m] ?cc " or " [m] z ret?rn from s?bro?tine the pro?ram co? nter is restored from the stack. pro?ram exec?tion contin?es at the restored address. pro?ram co?nter stack none ret?rn from s?bro?tine and load immediate data to ?cc the pro?ram co?nter is restored from the stack and the ?cc?m? lator loaded with the specifed immediate data. program execution continues at the restored address. pro?ram co?nter stack ?cc x none ret?rn from interr?pt the pro?ram co? nter is restored from the stack and the interr?pts are re-enabled by settin ? the emi bit. emi is the master interr?pt ? lobal enable bit. if an interr?pt was pendin ? when the reti instr? ction is exec?ted? the pendin? interr?pt ro?tine will be processed before ret?rnin? to the main pro?ram. pro?ram co?nter stack emi 1 none rotate data memory left the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. [m].(i+1) [m].i; (i = 0~6) [m].0 [m].7 none or a,[m] description operation affected fag(s) or a,x description operation affected fag(s) orm a,[m] description operation affected fag(s) ret description operation affected fag(s) ret a,x description operation affected fag(s) reti description operation affected fag(s) rl [m] description operation affected fag(s)
rev. 1.00 86 ????st 1?? ? 011 rev. 1.00 87 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu . rotate data memory left with res?lt in ?cc the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. the rotated res ?lt is stored in the ?cc?m? lator and the contents of the data memory remain ?nchan?ed. ?cc.(i+1) [m].i; (i = 0~6) ?cc.0 [m].7 none rotate data memory left thro??h carry the contents of the specifed data memory and the carry fag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry fag is rotated into bit 0. [m].(i+1) [m].i; (i = 0~6) [m].0 c c [m].7 c rotate data memory left thro??h carry with res?lt in ?cc data in the specifed data memory and the carry fag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry fag is rotated into the bit 0. the rotated res? lt is stored in the ?cc?m? lator and the contents of the data memory remain ?nchan?ed. ?cc.(i+1) [m].i; (i = 0~6) ?cc.0 c c [m].7 c rotate data memory ri?ht the contents of the specifed data memory are rotated right by 1 bit with bit 0 rotated into bit 7. [m].i [m].(i+1); (i = 0~6) [m].7 [m].0 none rotate data memory ri?ht with res?lt in ?cc data in the specifed data memory and the carry fag are rotated right by 1 bit with bit 0 rotated into bit 7. the rotated res ?lt is stored in the ?cc?m? lator and the contents of the data memory remain ?nchan?ed. ?cc.i [m].(i+1); (i = 0~6) ?cc.7 [m].0 none rotate data memory ri?ht thro??h carry the contents of the specifed data memory and the carry fag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry fag is rotated into bit 7. [m].i [m].(i+1); (i = 0~6) [m].7 c c [m].0 c rla [m] description operation affected fag(s) rlc [m] description operation affected fag(s) rlca [m] description operation affected fag(s) rr [m] description operation affected fag(s) rra [m] description operation affected fag(s) rrc [m] description operation affected fag(s)
rev. 1.00 86 ????st 1?? ? 011 rev. 1.00 87 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu rotate data memory ri?ht thro??h carry with res?lt in ?cc data in the specifed data memory and the carry fag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry fag is rotated into bit 7. the rotated res?lt is stored in the ?cc?m? lator and the contents of the data memory remain ?nchan?ed. ?cc.i [m].(i+1); (i = 0~6) ?cc.7 c c [m].0 c s?btract data memory from ?cc with carry the contents of the specifed data memory and the complement of the carry fag are s? btracted from the ?cc?m? lator. the res?lt is stored in the ?cc?m? lator. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. ?cc ?cc D [m] D c ov ? z? ?c? c s?btract data memory from ?cc with carry and res?lt in data memory the contents of the specifed data memory and the complement of the carry fag are s? btracted from the ?cc?m? lator. the res? lt is stored in the data memory. note that if the result of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. ?cc ?cc D [m] D c ov ? z? ?c? c skip if decrement data memory is 0 the contents of the specifed data memory are frst decremented by 1. if the result is 0 the followin? instr? ction is skipped. ?s this req? ires the insertion of a d?mmy instr?ction while the next instr?ction is fetched? it is a two cycle instr? ction. if the res?lt is not 0 the pro?ram proceeds with the followin? instr?ction. [m] [m] D 1 skip if [m] = 0 none skip if decrement data memory is zero with res?lt in ?cc the contents of the specifed data memory are frst decremented by 1. if the result is 0? the followin? instr? ction is skipped. the res? lt is stored in the ?cc?m? lator but the specifed data memory contents remain unchanged. as this requires the insertion of a d ?mmy instr? ction while the next instr? ction is fetched? it is a two cycle instr ? ction. if the res? lt is not 0? the pro? ram proceeds with the followin ? instr?ction. ?cc [m] D 1 skip if ?cc = 0 none rrca [m] description operation affected fag(s) sbc a,[m] description operation affected fag(s) sbcm a,[m] description operation affected fag(s) sdz [m] description operation affected fag(s) sdza [m] description operation affected fag(s)
rev. 1.00 88 ????st 1?? ? 011 rev. 1.00 89 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu set data memory each bit of the specifed data memory is set to 1. [m] ffh none set bit of data memory bit i of the specifed data memory is set to 1. [m].1 1 none skip if increment data memory is 0 the contents of the specifed data memory are frst incremented by 1. if the result is 0? the followin? instr? ction is skipped. ?s this req? ires the insertion of a d?mmy instr? ction while the next instr? ction is fetched? it is a two cycle instr? ction. if the res?lt is not 0 the pro?ram proceeds with the followin? instr?ction. [m] [m] + 1 skip if [m] = 0 none skip if increment data memory is zero with res?lt in ?cc the contents of the specifed data memory are frst incremented by 1. if the result is 0? the followin? instr? ction is skipped. the res?lt is stored in the ?cc?m? lator but the specifed data memory contents remain unchanged. as this requires the insertion of a d ? mmy instr? ction while the next instr? ction is fetched? it is a two cycle instr? ction. if the res? lt is not 0 the pro? ram proceeds with the followin? instr?ction. ?cc [m] + 1 skip if ?cc = 0 none skip if bit i of data memory is not 0 if bit i of the specifed data memory is not 0, the following instruction is skipped. ?s this req?ires the insertion of a d?mmy instr?ction while the next instr?ction is fetched? it is a two cycle instr? ction. if the res? lt is 0 the pro? ram proceeds with the followin? instr?ction. skip if [m].i 0 none s?btract data memory from ?cc the specifed data memory is subtracted from the contents of the accumulator. the res ? lt is stored in the ?cc? m? lator. note that if the res ? lt of s ? btraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. ?cc ?cc D [m] ov ? z? ?c? c set [m] description operation affected fag(s) set [m].i description operation affected fag(s) siz [m] description operation affected fag(s) siza [m] description operation affected fag(s) snz [m].i description operation affected fag(s) sub a,[m] description operation affected fag(s)
rev. 1.00 88 ????st 1?? ? 011 rev. 1.00 89 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu s?btract data memory from ?cc with res?lt in data memory the specifed data memory is subtracted from the contents of the accumulator. the res? lt is stored in the data memory. note that if the res?lt of s? btraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. [m] ?cc D [m] ov ? z? ?c? c s?btract immediate data from ?cc the immediate data specifed by the code is subtracted from the contents of the ? cc ?m? lator. the res? lt is stored in the ? cc ?m? lator. note that if the res ? lt of subtraction is negative, the c fag will be cleared to 0, otherwise if the result is positive or zero, the c fag will be set to 1. ?cc ?cc D x ov ? z? ?c? c swap nibbles of data memory the low-order and hi ? h-order nibbles of the specified data memory are interchan?ed. [m].3~[m].0?[m].7 ~ [m].4 none swap nibbles of data memory with res?lt in ?cc the low-order and hi ? h-order nibbles of the specified data memory are interchan ? ed. the res? lt is stored in the ?cc?m? lator. the contents of the data memory remain ?nchan?ed. ? cc.3 ~ ?cc.0 [m].7 ~ [m].4 ? cc.7 ~ ?cc.4 [m].3 ~ [m].0 none skip if data memory is 0 if the contents of the specified data memory is 0 ? the followin ? instr? ction is skipped. ?s this req?ires the insertion of a d?mmy instr? ction while the next instr?ction is fetched? it is a two cycle instr?ction. if the res?lt is not 0 the pro?ram proceeds with the followin? instr?ction. skip if [m] = 0 none skip if data memory is 0 with data movement to ?cc the contents of the specifed data memory are copied to the accumulator. if the val? e is zero? the followin? instr? ction is skipped. ?s this req? ires the insertion of a d?mmy instr? ction while the next instr? ction is fetched? it is a two cycle instr?ction. if the res?lt is not 0 the pro?ram proceeds with the followin? instr?ction. ?cc [m] skip if [m] = 0 none subm a,[m] description operation affected fag(s) sub a,x description operation affected fag(s) swap [m] description operation affected fag(s) swapa [m] description operation affected fag(s) sz [m] description operation affected fag(s) sza [m] description operation affected fag(s)
rev. 1.00 90 ????st 1?? ? 011 rev. 1.00 91 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu skip if bit i of data memory is 0 if bit i of the specifed data memory is 0, the following instruction is skipped. as this req ? ires the insertion of a d? mmy instr? ction while the next instr? ction is fetched? it is a two cycle instr?ction. if the res?lt is not 0? the pro? ram proceeds with the followin? instr?ction. skip if [m].i = 0 none read table to tblh and data memory the pro? ram code addressed by the table pointer (tbhp and tblp) is moved to the specifed data memory and the high byte moved to tblh. [m] pro?ram code (low byte) tblh pro?ram code (hi?h byte) none read table (last pa? e) to tblh and data memory the low byte of the pro ? ram code (last pa? e) addressed by the table pointer (tblp) is moved to the specifed data memory and the high byte moved to tblh. [m] pro?ram code (low byte) tblh pro?ram code (hi?h byte) none lo?ical xor data memory to ?cc data in the accumulator and the specifed data memory perform a bitwise logical xor operation. the res ?lt is stored in the ?cc?m? lator. ?cc ?cc " xor " [m] z lo?ical xor ?cc to data memory data in the specifed data memory and the accumulator perform a bitwise logical xor operation. the res ? lt is stored in the data memory. [m] ?cc " xor " [m] z lo?ical xor immediate data to ?cc data in the ?cc?m? lator and the specified immediate data perform a bitwise lo? ical xor operation. the res?lt is stored in the ?cc?m? lator. ?cc ?cc " xor " x z sz [m].i description operation affected fag(s) tabrd [m] description operation affected fag(s) tabrdl [m] description operation affected fag(s) xor a,[m] description operation affected fag(s) xorm a,[m] description operation affected fag(s) xor a,x description operation affected fag(s)
rev. 1.00 90 ????st 1?? ? 011 rev. 1.00 91 ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd 8-bit otp mcu package information 44-pin qfp (10mm10mm) outline dimensions                      symbol dimensions in inch min. nom. max. ? 0.51? D 0.5?8 b 0.390 D 0.398 c 0.51? D 0.5?8 d 0.390 D 0.398 e D 0.031 D f D 0.01? D g 0.075 D 0.087 h D D 0.106 i 0.010 D 0.0?0 j 0.0?9 D 0.037 k 0.004 D 0.008 l D 0.004 D 0 D 7 symbol dimensions in mm min. nom. max. ? 13.00 D 13.40 b 9.90 D 10.10 c 13.00 D 13.40 d 9.90 D 10.10 e D 0.80 D f D 0.30 D g 1.90 D ?.?0 h D D ?.70 i 0.?5 D 0.50 j 0.73 D 0.93 k 0.10 D 0.?0 l D 0.10 D 0 D 7
rev. 1.00 9? ????st 1?? ? 011 rev. 1.00 pb ????st 1?? ? 011 HT46R0664 enhanced a/d+lcd type 8-bit otp mcu holtek semiconductor inc. (headquarters) no.3? creation rd. ii? science park? hsinch?? taiwan tel: 886-3-563-1999 fax: 886-3-563-1189 http://www.holtek.com.tw holtek semiconductor inc. (taipei sales offce) 4f-?? no. 3-?? y ?anq? st.? nankan? software park? taipei 115? taiwan tel: 886- ?-?655-7070 fax: 886-?-?655-7373 fax: 886-?-?655-7383 (international sales hotline) holtek semiconductor inc. (shenzhen sales offce) 5f ? unit ?? prod?ctivity b?ildin?? no.5 gaoxin m ?nd road? nanshan district? shenzhen? china 518057 tel: 86-755-8616-9908 ? 86-755-8616-9308 fax: 86-755-8616-97?? holtek semiconductor (usa), inc. (north america sales offce) 467?9 fremont blvd.? fremont? c? 94538? us? tel: 1-510- ?5?-9880 fax: 1-510-?5?-9885 http://www.holtek.com copyri?ht ? ? 011 by holtek semiconductor inc. the information appearin? in this data sheet is believed to be acc? rate at the time of p? blication. however ? holtek ass ? mes no responsibility arisin? from the ? se of the specifications described. the applications mentioned herein are ? sed solely for the p? rpose of ill? stration and holtek makes no warranty or representation that such applications will be suitable without further modifcation, nor recommends the use of its prod ? cts for application that may present a risk to h?man life d? e to malf?nction or otherwise. holtek's prod?cts are not a? thorized for ?se as critical components in life s?pport devices or systems. holtek reserves the right to alter its products without prior notifcation. for the most up-to-date information, please visit our web site at http://www.holtek.com.tw .


▲Up To Search▲   

 
Price & Availability of HT46R0664

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X